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.

3
  • Hope this reference helps DOC1 , DOC2 and SO Commented Aug 23, 2023 at 1:55
  • git issues Commented Aug 23, 2023 at 2:04
  • deploy Commented Sep 2, 2023 at 13:38

1 Answer 1

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 .
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.