-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
Using koa as server side framework, status 404 occurs when load static files. #677
Comments
Would be great indeed to have a working Next-Koa example 🙂 |
Added example https://github.com/zeit/next.js/pull/800/files closing this |
The issue of serving static assets over Koa still exits on the latest master. I checked it through the example added by @impronunciable and can be reproduced. |
Yep it is. Here's the fix: #815 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I am trying using Koa as server side framework of my project. And I followed the example and got my koa's version below:
server.js:
But when load static files 'main.js' and 'common.js' in
.next
, the browser complains that these files are not found with status 404, but the content of the files are actually correct.I read the source code and found that next.js always tried to load gzip version of these files and if not found it would load the normal version.
So it actually run the serveStatic function twice. But the first time it tried to load gzip version but it failed then the
res
object got 404statusCode
, and the second the status code still retained inres
object of koa for some unknown reasons.Reseting status code in
serveStaticWithGzip
function fixed this problem:I am using koa@2 and next@beta.
(Poor English, feel free to correct.)
The text was updated successfully, but these errors were encountered: