stewartpark / Flask-JSGlue

Flask-JSGlue helps hook up your Flask application nicely with the front end.
80 stars 40 forks source link

URLs generated by Flask.url_for() missing application root #10

Closed elgow closed 7 years ago

elgow commented 8 years ago

My Flask application is deployed at a BASE_URL so that links to endpoints look like: http://my_server/BASE_URL/endpoint/... All URLs for Flask endpoints need to start with that BASE_URL. I find that links generated on the server side using {{ url_for(endpoint) }} work correctly, but links generated in Javascript on the client using Flask.url_for(endpoint) come out as http://my_server/endpoint/... with the application BASE_URL portion missing.

When viewed in a debugger both the flask server-side code and the jsglue client code seem to produce the same thing: "/endpoint/...", but the final URLs come out differently.

This may be user error, in which case I'd really appreciate some advice about how to solve it, or it may be a problem with URLs produced by jsglue.

italomaia commented 7 years ago

Example, from docs:

Flask.url_for("api.external_link", {"_external": true, "_scheme": "https", "_anchor": "main"})

Try it.

stewartpark commented 7 years ago

This was resolved by https://github.com/stewartpark/Flask-JSGlue/pull/22