Giter Site home page Giter Site logo

Comments (9)

pjvandehaar avatar pjvandehaar commented on August 14, 2024 1

If that doesn't work, it sounds like you should just edit the source code to use url_for(..., _external=True, _scheme="https") or whatever. I think a pull request wouldn't make sense because it's unlikely that the current pheweb has the same error.

from pheweb.

pjvandehaar avatar pjvandehaar commented on August 14, 2024

from pheweb.

CaliWee avatar CaliWee commented on August 14, 2024

You're right. urlprefix does not work like that. But I would be happy to make a PR for that new flag. I should get time in the next few weeks. I'll make a ticket for myself

from pheweb.

pjvandehaar avatar pjvandehaar commented on August 14, 2024

Okay, I'm surprised by the behavior you're reporting. Can you walk me through what's happening? Here's what I assume will happen:

  1. You run pheweb serve --port=8080.
  2. You run Nginx/Apache to serve "https://pheweb.example.com/" (port 443) by proxying to localhost:8080.
  3. You go to "https://pheweb.example.com/random", and it redirects you to "/pheno/728". That is, it returns "301 REDIRECT" with the header "Location: /pheno/738". That happens because get_random_page() returns "/pheno/738", which is a non-external URL because this function is being called inside of an "active request context".
  4. Your browser sends you to "https://pheweb.example.com/pheno/738" because it's a relative redirect.

Are you claiming that in this setup, you're redirected away from https to http? Could you share the console output of pheweb serve as this happens, and maybe also your apache/nginx logs?

Or are you using a setup that's different from what I described?

What version of pheweb and flask are you using?

from pheweb.

CaliWee avatar CaliWee commented on August 14, 2024

This is the setup that I am working with. It was surprising for me too as this is the only link that seems to redirect away from https to http.

Keep in mind, I am running a version of PheWeb that is 3 years old. Due to the requirements of the project / the data format I am unable to update at this moment.

pheweb==1.1.14
flask==1.0.3 # via flask-compress, flask-login, pheweb

from pheweb.

pjvandehaar avatar pjvandehaar commented on August 14, 2024

Oh. What happens if you add this line to server.py:

app.config['PREFERRED_URL_SCHEME'] = 'https'

from pheweb.

CaliWee avatar CaliWee commented on August 14, 2024

Makes sense. I'll give those a try. Thanks!

from pheweb.

CaliWee avatar CaliWee commented on August 14, 2024

After adding url_for(..., _external=True, _scheme="https") to all of the url_for calls in get_random_page and specifying proxy_set_header Host $http_host; before proxy_pass in my nginx.conf this issue was solved for me. Like you said, it's probably not an issue in the more recent versions and hopefully I can convince stakeholders to upgrade soon. Thanks!

from pheweb.

pjvandehaar avatar pjvandehaar commented on August 14, 2024

from pheweb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.