Handling of double slashes in URLs

I’m running a Gunicorn/Flask app on a Fly machine. I’ve noticed recently that, unlike other places I have deployed apps, it doesn’t seem like request URLs get fully normalised to remove any duplicate slashes (ie https://test-app.fly.dev/test//url should be mapped to https://test-app.fly.dev/test/url). I have noticed it working in a limited way (https://test-app.fly.dev//test/url was mapped to https://test-app.fly.dev/test/url), but not in all cases

As I understand it this is something typically handled by the OS or web server being used (see here). I could stick an Nginx server in front of my app, but I’m not sure if I understand why this couldn’t also be handled on Fly’s end (since when I have multiple machines there must be some web server sitting in front of my apps) – unless I’m misunderstanding something!

Any help appreciated :slight_smile:

AFAIK double forward slashes normalisation nowadays is done both by most modern browsers before sending the request to the server and by most web servers, as you write.

In your case your web server is Gunicorn which I believe does NOT do normalisation (but do check). If I’m right then you’d need to either put a reverse proxy in front of it, e.g. NGINX, or do path normalisation in code, e.g. leveraging Flask’s before_request decorator.

Fly doesn’t put a webserver in front of your machines, it’s up to you to do so if you need one (you can deploy anything on machines, not just web apps) and I don’t think Fly Proxy does normalisation.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.