Code Monkey home page Code Monkey logo

Comments (5)

MuhammadNaeem42 avatar MuhammadNaeem42 commented on July 18, 2024

i will help you to setup this application
contact me https://www.fiverr.com/s/9W3PNA
simple

from app.

muxo771 avatar muxo771 commented on July 18, 2024

Is this the same for the 4.6.x beta?
Seems to have no effect.

from app.

bonnerl avatar bonnerl commented on July 18, 2024

@muxo771 SimpleLogin doesn't currently support APPLICATION_ROOT for 3.x or 4.6.x.

from app.

leor-gh avatar leor-gh commented on July 18, 2024

I had the same use case requirement to host SImpleLogin not under web server ROOT but another path. I spent a few hours yesterday afternoon to fix the code and achieved it. And today I stumbled upon this issue.

Disclaimer I have not done any serious Python programming before, other than being aware of its syntax. I know even less about Flask (didn't hear about it before), and what I did may not be the "right" way.

APPLICATION_ROOT is a Flask thing, but it seems to be related to middle dispatcher, which SL does not use. Adding it may be quite a task.

What I did was simply adjusting the url_prefix (adding the prefix I want) when registering the blueprints in server.py (there are 10 blueprints) and prepending the prefix when adding the routes for the app (e.g. /favicon.ico). Then all the generated URLs will have the correct /path prefixes. I also changed the default "static" path to /path/static to take care of serving the static files.

The remaining issues are the HTML templates have mixed references to /static and /api Some places are hard-coded with /static while some use url_for('static'). The latter generates the correct path. Same goes for the /api path.

Then in nginx.conf, I pass the /path prefix from the URL to proxy_pass so SL receives the expected full path.

Once that is all done, SL works as expected. Only a few "routes" are not changed, but they are related to functionality I don't care/need, like OpenID, Paddle, Coinbase, etc.

Hope this helps.

from app.

leor-gh avatar leor-gh commented on July 18, 2024

There is a thread on stackoverflow discussing the same issue: (https://stackoverflow.com/questions/67737069/how-to-host-a-flask-app-on-a-subfolder-url-prefix-with-nginx/75123044)

One solution seems to be simply as adding a couple new imports and then APPLICATION_ROOT should work as intended.

Another one is adding a new argument to ProxyFix in server.js, which SL is already using. In nginx configuration, be sure to add the trailing / to proxy_pass so that it will remove the prefix when passing the URL to the server. SL can then process all the URLs correctly.

On generating URL, Flask will add the prefix as passed in via the X-Forwarded-Prefix to all generated URLs. This takes care of most URLs from the application.

However, as mentioned, quite a few files in the templates are hard coded with /static and /api and they need to be changed with using url_for as appropriate so that URLs are generated correctly.

I tested X-Forwarded-Prefix set up and the app is working fine for the functionality I use. My Android client also works with API access once I update the server URL.

from app.

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.