In my project, I have a registration flow that takes the user to a URL like http://localhost:8080/awaiting-confirmation/username@example.com. Doing pushUrl from the Elm side works fine. However, refreshing this page in the browser causes an error: Cannot GET /awaiting-confirmation/username@example.com.
I believe this is due to the code here that analyzes the URL to determine what file type the request is trying to get, in order to determine whether to try to serve a static file or to serve the root page:
Because this is guessing based on the "extension", any URL that ends in .com is assumed to be a static file.
At first I thought this was a problem with the URL parsing in the path component of a URL, so I also tried as a query string: http://localhost:8080/awaiting-confirmation?email=username@example.com. Unfortunately this gave me the same result (Cannot GET /awaiting-confirmation). I don't like the behavior on just paths, but I think the same behavior on query parameters is definitely wrong.
I can think of a few ways we could try to fix this:
Instead of guessing that the path is static because of its mimetype, we could assume any path that we can stat() successfully is static.
We could be more opinionated about insisting that static assets be located under certain well-known directories such as public or static.
This is a very good point and something that I didn't have a lot of cases to test the edges of. Would love your thoughts on solutions for this in the code. :)
In my project, I have a registration flow that takes the user to a URL like
http://localhost:8080/awaiting-confirmation/username@example.com
. DoingpushUrl
from the Elm side works fine. However, refreshing this page in the browser causes an error:Cannot GET /awaiting-confirmation/username@example.com
.I believe this is due to the code here that analyzes the URL to determine what file type the request is trying to get, in order to determine whether to try to serve a static file or to serve the root page:
https://github.com/wking-io/elm-live/blob/e9af6ecee3a8b1ea9261927a1e6c7377505aab3f/lib/src/start.js#L109-L110
Because this is guessing based on the "extension", any URL that ends in
.com
is assumed to be a static file.At first I thought this was a problem with the URL parsing in the path component of a URL, so I also tried as a query string:
http://localhost:8080/awaiting-confirmation?email=username@example.com
. Unfortunately this gave me the same result (Cannot GET /awaiting-confirmation
). I don't like the behavior on just paths, but I think the same behavior on query parameters is definitely wrong.I can think of a few ways we could try to fix this:
stat()
successfully is static.public
orstatic
.