0

I try to run NextJS development server with SWA emulator. After enabling SSL, emulator crashes after first request. If I do static export of the NextJS site and use that folder with emulator, everything works correctly.

Any ideas what could go wrong? I have tried older versions of SWA Cli + disabled NVM and installed NodeJS directly.

Everything is also described here: https://github.com/Azure/static-web-apps-cli/issues/741

swa-cli.config.json

{
  "$schema": "https://aka.ms/azure/static-web-apps-cli/schema",
  "configurations": {
    "new-swa-test": {
      "appLocation": ".",
      "outputLocation": ".next",
      "appBuildCommand": "npm run build",
      "run": "npm run dev",
      "appDevserverUrl": "http://localhost:3001",
      "ssl": true,
      "verbose": "silly"
    }
  }
}

package.json scripts

"scripts": {
    "dev": "next dev -p 3001",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
},

Output after 'swa start' (certification details snipped away)

[swa] node "C:\Users\heinonenjj\AppData\Roaming\nvm\v18.14.0\node_modules@azure\static-web-apps-cli\dist\msha\server.js" exited with code 0 --> Sending SIGTERM to other processes.. [run] cd "C:\code\swa-test\new-swa-test" && npm run dev exited with code 1 ✖ SWA emulator stoped because the --run command exited with code 1.

  • Hope this reference helps [DOC1](https://azure.github.io/static-web-apps-cli/docs/cli/swa-init) , [DOC2](https://azure.github.io/static-web-apps-cli/docs/use/emulator/) and [SO](https://stackoverflow.com/questions/73666601/how-do-you-deploy-a-next-js-app-using-swa-cli-for-azure-static-apps) – Sampath Aug 23 '23 at 01:55
  • git [issues](https://github.com/vercel/next.js/issues/28114) – Sampath Aug 23 '23 at 02:04
  • [deploy](https://dev.to/azure/deploy-next-js-with-azure-static-web-app-service-and-github-actions-32j0) – Sampath Sep 02 '23 at 13:38

1 Answers1

0
  • I am able to run by setting "SSL": true

  • Created a Next JS with the command npx create-next-app@latest nextjs-blog

  • I have used the MSDOC reference to setup Next JS

npx create-next-app@latest nextjs-blog

  • Make sure to build the application npm run build and added , local SSL with Next.js and git.
  • create local-server.js
  • To create a SWA Cli in the next js application use swa init

enter image description here

enter image description here

enter image description here

{

"$schema":  "https://aka.ms/azure/static-web-apps-cli/schema",

"configurations":  {

"nextjs-blog":  {

"appLocation":  ".",

"outputLocation":  ".next",

"appBuildCommand":  "npm run build",

"run":  "npm run dev",

"appDevserverUrl":  "http://localhost:3000",
"ssl":  true
}
}
}

used swa start to run

  • Deployed the app with swa deploy

enter image description here

Local Output: enter image description here

Azure :

enter image description here

  • For more details reference SSL with NextJS dev server and git .
Sampath
  • 810
  • 2
  • 2
  • 13