Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
318 stars 53 forks source link

Nextjs backend call failure #1444

Open krisnashaypp opened 3 months ago

krisnashaypp commented 3 months ago

We have a nextjs app that has been running as a static web app for many months, in recent days it has started having intermittent failures were all you see is "Backend call failure", usually it starts working by itself after a while but sometimes it takes a longer time.

image

It's running next 13.5.6, thanks

janosgy commented 1 month ago

After struggling from the same problem, this is how I fixed it for my app. First, no work around worked for me on Azure static web app even the paid plan! So I shifted to Azure app service and it won't work until you include some files and modifications. I wrote all about it and added the files needed, code and references here Just jump to the solution part.

I hope this helps.

@EmanH5 I also migrated to App Service, but there was no need to do manual configuration or change the scripts in the package.json. This is the guide I followed: https://dev.to/paulriviera/deploy-nextjs-14-app-to-linux-azure-app-service-3d34 and I think most of the things are done automatically because of the standalone output config.

EmanH5 commented 1 month ago

After struggling from the same problem, this is how I fixed it for my app. First, no work around worked for me on Azure static web app even the paid plan! So I shifted to Azure app service and it won't work until you include some files and modifications. I wrote all about it and added the files needed, code and references here Just jump to the solution part. I hope this helps.

@EmanH5 I also migrated to App Service, but there was no need to do manual configuration or change the scripts in the package.json. This is the guide I followed: https://dev.to/paulriviera/deploy-nextjs-14-app-to-linux-azure-app-service-3d34 and I think most of the things are done automatically because of the standalone output config.

@janosgy That's weird, I tried it without changing package.json but it didn't work at all. in my experience, the only approach that worked with me was adding the server and config files I mentioned and change package.json scripts to node Maybe it depends on next's version then? not sure really but at least it seems for sure needs to be an Azure app service to work 👍🏻

sellimenes commented 1 month ago

It is unacceptable and shameful for Azure to leave such a serious problem unexplained. We have switched from Azure SWA to IIS. Everything works much much faster, the build configuration is much easier, and we are not encountering any unexplained errors. For those experiencing the problem, the only absolute solution seems to be not using SWA...

NOTE: We were using paid plans.

mfathi91 commented 1 month ago

@janosgy @EmanH5 we also have a Next.js static web app (where both frontend and backend are hosted on the static web app itself). Did you guys move your backend only to Azure App Service? Or your entire application?

This is how I do it on Azure, but I get "Internal Server Error":

  1. Create an app service plan with P1V3 tier, with Linux OS.
  2. Create a web app an associate it with the app service plan.
  3. In Azure portal, go to the static web app -> APIs -> Configure linked backend -> add the created linux web app
victorpotasso commented 1 month ago

We also moved to app service. So far so good. We also noticed the application is performing better. It also catch more next.js exceptions to App Insights

charlower commented 1 month ago

Experiencing the same issue for a while now.

EmanH5 commented 1 month ago

@janosgy @EmanH5 we also have a Next.js static web app (where both frontend and backend are hosted on the static web app itself). Did you guys move your backend only to Azure App Service? Or your entire application?

This is how I do it on Azure, but I get "Internal Server Error":

  1. Create an app service plan with P1V3 tier, with Linux OS.
  2. Create a web app an associate it with the app service plan.
  3. In Azure portal, go to the static web app -> APIs -> Configure linked backend -> add the created linux web app

@mfathi91 I moved the entire app to Azure app service and it is working smoothly now with the configurations I mentioned in my post. Your steps also make sense as another approach that could work if you want to only move the backend but since you have internal server error then there might be an issue with the APIs setup or the Access permissions to the Azure App service. Maybe CORS? not sure.

lucavgobbi commented 1 month ago

We've been having the same issue, what has helped is trying to update a dummy "environment variable" to trigger a back-end restart. If that doesn't help, trigger the same deploy has helped.

philipmuller commented 4 weeks ago

Same issue here. Paid SWA service in West Europe. Only fix is redeploying

mrcportillo commented 4 weeks ago

Same issue here with paid SWA service. 🔥 🔥

alexeisolodovnicov-tomtom commented 4 weeks ago

Hybrid NextJS apps are still in Preview, so MSFT support wouldn't help much. The only way seems to jump to Azure App Service.

ElHawary-Ebutler commented 3 weeks ago

Same issue.

ZachDenholm commented 3 weeks ago

Same issue NextJS 14 on Paid SWA service

vartdalen commented 3 weeks ago

Same issue Next.js 14.2.3 with NextAuth 4.24.7, redeploying seems to fix the problem - after redeploying yesterday, the issue has not resurfaced yet.

mrcportillo commented 3 weeks ago

After several days with the same issue I moved to app services. Used this guide for the project setup https://dev.to/paulriviera/deploy-nextjs-14-app-to-linux-azure-app-service-3d34 and as I'm using azure pipelines I followed this https://www.azure365pro.com/deploy-next-js-app-on-azure-app-service-with-azure-devops-pipelines-2/ for the pipeline script and the service connection configuration. Something to point out, had some issues when using the free tier app service layer, after moved to the paid one it just worked 🤑

krisnashaypp commented 3 weeks ago

OP here, I moved my app to Azure Container Apps and i've been very pleased with that service so far. With little knowledge about docker and ACA I was able to get up and running within a day and now I'm moving my backend into the same service since you get a lot of synergies. I recommend everyone give it a look before automatically going with app service.

JiRadu commented 3 weeks ago

I moved from it to vercel. For the life of me, I couldn't find a fix no matter how much I refactored my code. Muck Ficrosoft on this one

TimKerre commented 3 weeks ago

Same issue here, using NextJS 14 on Paid SWA service

ChandanRabha commented 2 weeks ago

Experiencing the same issue, build runs no issue locally, but when done on azure pipelines sometimes build is created successfully and sometimes it isn't. And the error message of the post. Using Next 14

hrc7505 commented 2 weeks ago

We are facing same issue Nextjs: 14.2.3 Node: 20.11.0

tommykri commented 2 weeks ago

We are also experiencing the same issue on a paid SWA service and is considering other options if this isn't fixed soon. Occasionally the API routes is very slow or we get the error message "Backend call failure".

janosgy commented 2 weeks ago

I believe this issue will only grow. It seems that Azure functions are not production-ready. If you can, move away from Azure, if you can't, migrate to App Service.

dharmendrasha commented 2 weeks ago

same here

TomiwaPhilip commented 2 weeks ago

I am also experiencing the same issue

dharmendrasha commented 2 weeks ago

for those who are suffering this fixed my issue.

https://github.com/Azure/static-web-apps/issues/1496#issuecomment-2168383060

jenspettersson commented 2 weeks ago

for those who are suffering this fixed my issue.

#1496 (comment)

I think most of us in this thread have issues with the application suddenly stops working with the "Backend call failure" message. The deploys have been flaky but I don't think that's the real underlying issue.

We had "Backend call failure" this morning and a re-deployed "fixed" it, but I can assure you we will soon see the "Backend call failure" again. Just happy we're not using it for anything else than a small internal app... Even so, we're currently migrating away from SWA and will use Container Apps instead as this is not acceptable at all.

vartdalen commented 2 weeks ago

After redeploying upon encountering this issue a week ago, the issue was temporarily fixed until today. Had to redeploy again for temporary fix. Microsoft, please look at this issue. Edit 2 hours later: Got the error again just now, after having redeployed earlier... This is the first time that we experience such a high frequency of the error.

Note that no code changes have been made to the project for many weeks.

jenspettersson commented 2 weeks ago

We've now moved away from SWA to Azure Container Apps and the migration was a breeze. It feels so much more stable now. It isn't free, but it's very cheap.

I used this example to start us off: https://github.com/vercel/next.js/tree/canary/examples/with-docker

mike-rambil commented 1 week ago

Same issue here as well..

designitsecure commented 1 week ago

Adding my voice to the chorus of those running into this issue. I was really hoping SWA would be a viable solution. Off I go to build a container I guess....

mike-rambil commented 1 week ago

same issue here

LifeLike1 commented 1 week ago

same issue

iwgarcia commented 17 hours ago

same issue here