-
Notifications
You must be signed in to change notification settings - Fork 48
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
Server returns response, not file #66
Comments
Hey there! Does this reference example code we got wrong? I saw there are talks about that in Slack. The first code sample you show will only serve index.html because, as you've figured out, it's hard-coded in there. We provide basic functionality for people to arrange in whatever way they need to make things work for their use cases. In your second example, that seems like what you're trying to do: for every request, check if the path is available as file. The response from this fetch could be a 404 if the file is not found. If you're trying to load an image, then you're not setting the right content-type header though. We strongly encourage people to write their own routing logic or use a package that can do that for them. Since there's only one "fetch" handler (that I think we should make that clearer, for sure. As for your solution description:
I'm not sure I understand it. Maybe we need an example app that serves files from pathnames as best it can. This also makes me wonder if we should try to infer the content-type to avoid confusion and easy-to-make mistakes. What's the problem you want to solve? I believe the functionality works as intended. We could use a better example for it though :) |
I think we could make a basic static site app that does both of these pretty quickly. It'll be especially useful when we have globbing. |
After thinking about it, this was not a great idea and I think it would probably create more issues than it would solve. Documentation is probably the best rout in order to help people understand how it is supposed to be used. Another solution might be doing something similar to what express does and have something like this: app.use(express.static('public')) For inferring the content-type, I completely agree - this would be a great feature. I am happy to write some documentation on how to serve files, I am just not sure where the best place to do that would be. Maybe in a wiki? |
The following code will return the contents of
index.html
for everything.This is a problem because if
index.html
references a resource file likeimage.png
, the contents ofimage.png
will be the contents ofindex.html
.Possible Solution
All file url paths that are in
.fly.yml
should be overwritten and only return that file unless otherwise specified.Current Workaround
This code works properly:
Reproducible here: https://github.com/pudility/fly-error
The text was updated successfully, but these errors were encountered: