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

Next.js middleware not running on 13.4.13 #1266

Closed
jessebs opened this issue Sep 2, 2023 · 23 comments
Closed

Next.js middleware not running on 13.4.13 #1266

jessebs opened this issue Sep 2, 2023 · 23 comments

Comments

@jessebs
Copy link

jessebs commented Sep 2, 2023

Describe the bug

I have a working middleware.ts in Next.js that stopped working when I updated Next.js to 13.4.13. I am deploying the app as a static web app. Downgrading to 13.4.12 resolves the issue.

@sebastian-worcay
Copy link

I have the same issue here.

@atsd34
Copy link

atsd34 commented Sep 6, 2023

I have same issue nexauth middleware doesn't work with 13.4.19 downgrading to 13.4.12 didn't solve the issue.

@nth-prime
Copy link

I still have this problem. I have a call with Azure support this evening.

Per the documentation at https://learn.microsoft.com/en-us/azure/static-web-apps/deploy-nextjs-hybrid I tried this on Next.js 12.3.2 to no avail.

@evenhagen
Copy link

I still have this problem. I have a call with Azure support this evening.

Per the documentation at https://learn.microsoft.com/en-us/azure/static-web-apps/deploy-nextjs-hybrid I tried this on Next.js 12.3.2 to no avail.

Any updates after your call with Azure support?

@nth-prime
Copy link

I guess it should come as no surprise that support was not helpful. I have been trying to communicate with them for the last 36 hours.

The gist was that Next.js support for Azure Static Web Apps is in preview so they can't and won't assist in any way. Including suggesting another best practice for this type of deployment on Azure.

I'm working on retooling this for Vercel currently.

@rbourdon
Copy link

rbourdon commented Sep 13, 2023

I have this issue as well, and downgrading to 13.4.12 resolved did not resolve it for me. Middleware partially works with 13.4.12 and doesn't work at all with later versions (including new 13.5.1 release).

Seems like a caching problem to me, very inconsistent. Logs in app insights don't offer many clues.

@alexrabin
Copy link

alexrabin commented Sep 21, 2023

Might be related to these
vercel/next.js#46722 - it says Middleware is only available on the edge and not on node.js
vercel/next.js#48441 (comment)

@rbourdon
Copy link

Might be related to these vercel/next.js#46722 - it says Middleware is only available on the edge and not on node.js vercel/next.js#48441 (comment)

It's limited to the edge runtime API but will run in node. I'm using next-auth's middleware, no node APIs. It's working okay for me with 13.4.12 or earlier except on cached SSG pages

@sebastian-worcay
Copy link

sebastian-worcay commented Sep 25, 2023

Hi guys,
regarding middleare there was some discussion on AWS related to it having the same issue:
aws-amplify/amplify-hosting#3641

The root cause for middleare to be broken seems to be:
vercel/next.js#52492

Would like to get an update on this from the Azure Statitc Web App Team as middleware is still broken on Azure using Next.js with version greater than 13.4.12.

@sebastian-worcay
Copy link

Rechecked on 13.5.4 and still an issue.

@rickliveshere
Copy link

I would also suggest this is still an issue since 13.4.13 as well. I've deployed a standalone version of NextJS @ 13.4.12 to Azure SWA - this works fine, however upgrading beyond this results in core JS files returning a 404 - in most cases this appears due to loading assets through /_next/static/chunks/[generated-file].js being proxied and loaded via our generic pages/[...slug].ts path (invoking getStaticProps and returning a 404 when realising it's not a legitimate page slug).

This routing issue maybe related to middleware as above, but means we cannot upgrade beyond this point. We're using the 'pages' router for reference, and looking to test with a blank install of NextJS later today.

@gvffelisberto
Copy link

gvffelisberto commented Oct 11, 2023

Same issue here :(

TBH I dont think that the middleware feature fits into the "preview" category. You may use it to work entirely with SSG and i18n all together with App Router and a headless cms at build.

Also it is not stated that the middleware is not supported here.

@thomasgauvin any suggestion to get this working with the latest version of next(13.5.4)? Thank you in advance :)

May help: amplify-hosting

It does works as expected for v13.4.11, but downgrading is just not nice :-/

@rbourdon
Copy link

TBH I dont think that the middleware feature fits into the "preview" category. You may use it to work entirely with SSG and i18n all together with App Router and a headless cms at build.

Also it is not stated that the middleware is not supported here.

It's specifically mentioned as a supported feature on this page. I had some trouble even on 13.4.11/12 using SSG and next-auth :(

@sebastian-worcay
Copy link

Still an issue with latest next.js 13.5.6.

@daniel-soli
Copy link

any news on this issue?

@sebastian-worcay
Copy link

As next.js 14 is announced and this is still an issue on azure side I am really considering if we need to move our Next.js web application to some other hosting provider than azure. 😢
Saddens me because I am usually more than happy with Azure products.

@bertrand-riviere
Copy link

indeed, this is really a showstopper ☹.
since AWS has managed to fix the same issue (aws-amplify/amplify-hosting#3641 (comment)), I don't understand why Azure team couldn't.

@lobatolais
Copy link

Any updates? 😔

@changeworld
Copy link

Same issue here :(
This is still an issue on azure side I am really considering if we need to move our Next.js web application to some other hosting provider than azure :(
Saddens me because I am usually more than happy with Azure products.

@rickliveshere
Copy link

Are there any updates or a roadmap for when this issue may be resolved by the team?

I've seen in other threads that infrastructure changes may be required in Azure to more broadly support app based routing, indicating months, though it would be good to have an understanding of this so we can make a decision how to resolve.

We've been holding off doing a NextJS upgrade due to the middleware issue in this ticket, however we may need to consider migrating to an alternative platform as a security vulnerability requires an upgrade (see GHSA-c59h-r6p8-q9wc). Please could anyone from the SWA team advise?

@thomasgauvin
Copy link
Contributor

thomasgauvin commented Dec 11, 2023

For the preview, Next.js support is limited on Azure Static Web Apps for versions 13 and above, including the app router and React Server Components. We are actively working on our Next.js story and iterating, and expect to have a few updates in the first half of 2024. For the moment though, if a more reliable solution is needed, App Service or Container Apps may be possible solutions.

@gvffelisberto
Copy link

It would be nice to have that disclaimer about version 13 before, like 3 months ago.... at least thank you for the feedback and making clear that at least Static HTML export is fully supported.

@thomasgauvin
Copy link
Contributor

thomasgauvin commented Mar 7, 2024

Hi folks! This issue is now resolved with our improvements to Next.js support on Static Web Apps, with support for Next.js 13 & 14 and server features. I'll be closing this thread, please try out the newest improvements and let us know how it goes in the announcement thread: #1428

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests