next.js

Locally developing NextJS and fetch getting self signed cert error


I'm new to NextJS. I'm writing an app using NextJS for the front end and .NET Core API on the back end.

Usually, I can have visual studio create a self signed cert to run my apis with SSL and then have front end apps use that self signed cert to run things locally (at least I've done this with Angular without any issues).

I'm not sure how to do this with NextJS. My fetch command in my nextjs API, is failing because of the self-signed cert. Is there an easy way to tell NextJS that while I'm running localhost, ignore that a self signed cert is in the chain?


Solution

  • If you haven't already you need to setup a custom local server for NextJS because it doesn't support local development with SSL out of the box. Here is a guide on how to do that. This is a highly requested feature for NextJS.

    Update Jan 2024:

    As of NextJS 13.5.1 you can use https with the flag --experimental-https