Skip to content
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

Edge Functions cause 500 Error with [email protected] #34566

Closed
1 task done
lidqqq opened this issue Feb 19, 2022 · 3 comments · Fixed by vercel/examples#158
Closed
1 task done

Edge Functions cause 500 Error with [email protected] #34566

lidqqq opened this issue Feb 19, 2022 · 3 comments · Fixed by vercel/examples#158
Labels
bug Issue was opened via the bug report template. Middleware Related to Next.js Middleware.

Comments

@lidqqq
Copy link

lidqqq commented Feb 19, 2022

Verify canary release

  • I verified that the issue exists in Next.js canary release

Provide environment information

on Vercel, the runtime is Node.js v14

What browser are you using? (if relevant)

Chrome Chrome 98.0.4758.102 (Official Build) (arm64)

How are you deploying your application? (if relevant)

Vercel

Describe the Bug

I ran into a bug about Edge Functions with [email protected].
Edge Function causes a 500 error on Vercel, but local development doesn't cause them. So you can find them only when you deploy to Vercel so far.

https://ab-testing-simple-12-1.vercel.app/

Screen Shot 2022-02-19 at 10 43 19

And canary version causes it too

https://ab-testing-simple-canary.vercel.app/

But it works correctly with [email protected]
https://ab-testing-simple-12-0-x.vercel.app/

I got the same bug on my other production project that Edge Functions uses. Perhaps all of the Edge Functions cause 500 error regardless of how they use.

Expected Behavior

behave as well as the before versions such as [email protected]
https://ab-testing-simple-12-0-x.vercel.app/

To Reproduce

Or you can use these repositories that I used for my research

cause 500 error after v12.1

https://github.com/lidqqq/ab-testing-simple-12.1
https://github.com/lidqqq/ab-testing-simple-canary

works correctly

https://github.com/lidqqq/ab-testing-simple-12.0.x

@lidqqq lidqqq added the bug Issue was opened via the bug report template. label Feb 19, 2022
@balazsorban44
Copy link
Member

balazsorban44 commented Feb 19, 2022

Hi, thank you for reporting this!

I could identify the problem and mentioned it to the relevant team. Luckily, this is not a bug in Next.js, only that our examples should be updated to reflect #33410.

You should see an error in your Vercel Dashboard that points to this page:
https://nextjs.org/docs/messages/middleware-relative-urls#possible-ways-to-fix-it

I deployed a version that works here: https://balazsorban-34566-balazsorban.vercel.app/

The code changes needed are in the two _middleware files respectively:

const destination = req.nextUrl.clone()
destination.pathname = `/home/${bucket}` // or /marketing
const res = NextResponse.rewrite(destination)

@lidqqq
Copy link
Author

lidqqq commented Feb 20, 2022

@balazsorban44 Thanks for replying and investigating 🙏
I got it, and I opened the PR so please check it when you have some time 👍

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. Middleware Related to Next.js Middleware.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants