Comments (3)
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 fly.http.respondWith
callback), you need to have some form of dispatcher for the logic.
I think we should make that clearer, for sure.
As for your solution description:
All file url paths that are in
.fly.yml
should be overwritten and only return that file unless otherwise specified.
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 :)
from fly.
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.
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.
from fly.
I'm not sure I understand it. Maybe we need an example app that serves files from pathnames as best it can.
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?
from fly.
Related Issues (20)
- Running Varnish on Fly HOT 2
- Secured API Key generation on the edge with Fly HOT 2
- Continuous deployment + [Various] HOT 2
- Continuous deployment with CircleCI HOT 8
- Continuous Deployment with Travis HOT 13
- Continuous Deployment using Github Actions HOT 1
- Continuous Deployment with Codeship HOT 1
- Continuous Deployment with Buddy.works HOT 1
- Using OpenResty for Authentication on Fly HOT 6
- JS renderer on fly HOT 20
- Text summarizer (based on BERT) as a service/API on fly HOT 10
- Data[base|store]s & Fly HOT 11
- Redis cache cluster HOT 3
- Web app firewall HOT 1
- Rust on Fly
- GraphQL at Edge HOT 1
- hands-on docs bug
- allow exposing multiple port range in machines API and fly.toml
- Machine API V2 and region add does not scale as expected HOT 1
- Typo on `App status: Suspended` description HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fly.