Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't consider nonexistant files as static #222

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

glasserc
Copy link

Fixes #209.

  • Only examine URL pathname when deciding whether a request should be handled statically.
  • If a file does not exist, don't try to serve it statically.

I'm pretty sure that the first fix, where we no longer regard the query string when examining what to do with a path, is good and correct.

However, having implemented the behavior where we only consider serving a file statically if it actually exists, I'm not sure how I actually like it. This behavior means we serve a 200 with a gibberish response on any incorrect path to an asset, which makes certain problems harder to find. On the other hand, it doesn't seem unreasonable for an Elm application to want to masquerade as e.g. ASP.NET or PHP, in which case it might want to serve URLs that end in e.g. .aspx or .php. It might make sense to carve out exceptions for certain well-known file types such as CSS, JS, .ico, .png, .jpg, or alternately revert this behavior entirely and make people like me put email addresses as query string arguments instead of paths. Thoughts?

@glasserc
Copy link
Author

I also ought to mention that the nginx configuration I was going to put in production says try_files $uri $uri/ index.html, so at least I'm consistent 😂. I'm not really sure how else I would implement a configuration for a SPA which would exclude things like favicon.ico unless I specified them explicitly (in which case I might as well just create a real file to use to fulfill those requests). So I guess I'm comfortable with a solution like the one I implemented in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

elm-live assumes any URL ending in .com is a static file
2 participants