-
Notifications
You must be signed in to change notification settings - Fork 86
[Bug]: next.js _middleware.js NextResponse.rewrite() returns 404, but works in netlify-cli #1266
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
Comments
Do you have password protection on your site on Netlify? That seems to be the issue in my case. Middleware does not seem to work with password protected sites on Netlify. |
You are correct that Edge Functions do not currently work with password protection. If that's not the issue, rewrite problems may be related to this issue, which is fixed in the latest version of the plugin. @christopherpickering It would be great if you could try deploying again and see if it works now. |
Thanks for the comments! The function was not using password protection. I'll give it a retry. |
@ascorbic thanks, I redid the deploy: https://app.netlify.com/sites/focused-banach-ee0636/deploys/626807debad45243099b1eb0 It used: @netlify/[email protected] from Netlify app I get the same response as before. Should I try anything else? |
Here's the related issue w/ more comments. This works fine in the netlify cli. |
Hey. Could you try enabling edge functions for middleware? You should set the environment variable |
Hey @ascorbic thanks! Here's the build: https://app.netlify.com/sites/focused-banach-ee0636/deploys/6269472b35bed1324c5f6f36 I did a clear cache + build, Still no go. |
The team at Netlify have now released the new You can find the documentation and additional information here: Next.js on Netlify The Thanks! |
Summary
Hi,
We have a next.js middleware function that serves a static file, and allows us to rename the file with an environment variable.
the original file is
/umami.js
, and with a ENV variable of "TRACKER_SCRIPT_NAME=something_cool", I need to access the same file with the url/something_cool.js
.The middleware works fine with running with netlify-cli locally, but when deployed to netlify, I get a 404 error on the custom url. I added console logging to the middleware and everything looks as-expected.
Steps to reproduce
To run locally:
create a .env file with
netlify dev
, from terminal.Here's the umami middleware:
A link to a reproduction repository
https://github.com/atlas-bi/website-analytics
Plugin version
4.2.7
More information about your build
netlify.toml
)What OS are you using?
Mac OS
Your netlify.toml file
`netlify.toml`
Your public/_redirects file
`_redirects`
# Paste content of your `_redirects` file here
Your
next.config.js
file`next.config.js`
Builds logs (or link to your logs)
Build logs
Link to logs
Function logs
Function logs
.next JSON files
generated .next JSON files
The text was updated successfully, but these errors were encountered: