nextjs
Setting Up Local HTTPS for Next.js Using mkcert
Simple Local HTTPS Setup for Next.js Using mkcert
Simple Local HTTPS Setup for Next.js Using mkcert
This guide shows how to run a Next.js project locally with HTTPS using a fake local domain like:
https://myshop.localdev:3443Step 1 — Add Local Domain to macOS Hosts File
Open Terminal:
sudo nano /etc/hostsAdd:
127.0.0.1 myshop.localdevSave the file and flush DNS:
How to Automatically Restore PM2 Apps After Server Reboot (Managed Hosting)<
How to Automatically Restore PM2 Apps After Server Reboot (Managed Hosting)
Overview
On managed servers without root access, PM2 processes do not automatically restart after a server reboot. This can cause all Node.js / Next.js applications to go offline.
To solve this, we use:
NextJs htaccess setting
The content of the .htaccess for nextjs application is
# Redirect traffic to your port 3001
DirectoryIndex
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)?$ http://127.0.0.1:3001/$1 [P,L]
to exclude a file from this rule (EX: test.txt) we can add this like
RewriteCond %{REQUEST_URI} !test\.txt [NC]
Full Code