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
Feature - Better static assets support #89
Comments
@mattdell Are you interested to contribute towards this? |
@danielcondemarin I’m willing to take a crack at it. Let me assess my workload on Monday and hopefully I can dedicate some time to this. 🙂 |
Looks like I'm good to spend a few days on this. Feel free to mark it as assigned to me. |
I've got this working, just need to write some unit tests to finish it off and then I'll raise a PR. Just to confirm, do we want to keep the existing routes configuration?
This scenario is no longer needed as you'd just use the public folder. Also, I've made the static and public folders configurable in serverless.yml so public could be assets if desired. I'm not sure if routes is in the existing stable version or whether this would be a breaking change. I don't mind either way, but at the moment it seems superfluous. |
No need to keep that for static routes. Page routes we have to keep for the time being until this lands: vercel/next.js#7607.
Don't worry about making it a breaking change, v2 is still in alpha. |
Closed by #92 |
Original discussion: #88
Motivation
Currently it is only possible to host static assets at the top level of the api gw domain, e.g. /robots.txt, /sw.js etc. Nested static routes doesn't work, e.g.
/static/bar.png
,/static/foo.txt
etc.Also, the existing approach doesn't follow nextjs convention for
static/
andpublic/
folders. Would be better to follow next's convention to ensure feature parity with the development server.Proposal
Add a catch all
/static/{proxy+}
route to api gateway that proxies to S3 static assets requests.Note that static assets will only be possible to host them under the static folder with this approach, which differs from the current api.
Host any files under
./public
in the top level path, resources such as robots.txt, favicon.ico etc.Nextjs docs: (https://github.com/zeit/next.js/#static-file-serving-eg-images)
Caveats
A better approach would be to have a CloudFront distribution in front of API Gateway. API Gateway data transfer out costs is $0.09 per GB whilst CloudFront is $0.085 for the first TB.
A separate feature request will be made to add CloudFront support for production deployments.
The text was updated successfully, but these errors were encountered: