Next.js Discord

Discord Forum

Https in local network

Unanswered
French Angora posted this in #help-forum
Open in Discord
French AngoraOP
Hi, currently I'm working on a dashboard that will only run in my friend LAN and one of the main concepts is the quick search through a QR code scan, problem: I cannot access the camera if I'm not over Https, any possible ways to achieve SSL and Https in my local network?

25 Replies

@French Angora Hi, currently I'm working on a dashboard that will only run in my friend LAN and one of the main concepts is the quick search through a QR code scan, problem: I cannot access the camera if I'm not over Https, any possible ways to achieve SSL and Https in my local network?
It is possible to achieve https in local development, but I don't think you need it... localhost is considered a secure context by default. I think if you are using something like 192.168... local IP to access the web server, you can try an alternative like ngrok or localtunnel
@Riday πŸ’™ If you are using vs code, it has built-in support for this - https://code.visualstudio.com/docs/editor/port-forwarding Otherwise, Consider checking these out - https://theboroer.github.io/localtunnel-www/ - https://www.npmjs.com/package/ngrok#global-install - https://web.dev/articles/how-to-use-local-https (HTTPS locally)
French AngoraOP
Thanks for the reply. I've looked through the links you provided, but they all seem to have features that I don't need for my application:

Localtunnel requires a password check and provides a link that changes every time.
Ngrok generates a link that changes every time.
The WebDev article mentions a certificate that is only valid for my machine.
However, I found something that's a bit closer to my needs: local-ssl-proxy. While this helps to some extent, all of my redirects still point to the local IP (192.168.1.X), and I can't port forward it. I really need a way to port forward it.

Maybe a better explanation from me will help in getting the assistance I need:

I have a Next.js application on my machine that uses SQLite, so hosting online platforms like Vercel are not an option (and I prefer to avoid them if possible). This application will be deployed on another computer with a release build, and I need other devices to connect to the application, preferably without the constraint of being on the same Wi-Fi network.

The connection between the application and the client must be HTTPS because it's the only way to access the Webcam API from Next.js. Preferably, the application should remain accessible via the same link (it's okay for it to be an IP address or a domain).
@French Angora Thanks for the reply. I've looked through the links you provided, but they all seem to have features that I don't need for my application: > Localtunnel requires a password check and provides a link that changes every time. > Ngrok generates a link that changes every time. > The WebDev article mentions a certificate that is only valid for my machine. However, I found something that's a bit closer to my needs: local-ssl-proxy. While this helps to some extent, all of my redirects still point to the local IP (192.168.1.X), and I can't port forward it. I really need a way to port forward it. Maybe a better explanation from me will help in getting the assistance I need: I have a Next.js application on my machine that uses SQLite, so hosting online platforms like Vercel are not an option (and I prefer to avoid them if possible). This application will be deployed on another computer with a release build, and I need other devices to connect to the application, preferably without the constraint of being on the same Wi-Fi network. The connection between the application and the client must be HTTPS because it's the only way to access the Webcam API from Next.js. Preferably, the application should remain accessible via the same link (it's okay for it to be an IP address or a domain).
Ngrok and localtunnel have the basic features of port forwarding... What you need to do is to just do something like npx ngrok http 3000 and it will forward your port 3000 to a domain where you can test your app
Ngrok used to allow you to use a custom subdomain
So, like riday.ngrok.app or something... I don't remember
I think even localtunnel
French AngoraOP
Yes thank you i have looked into it and for development it's fantastic and i will surely use it
Use a .env file to configure your redirects
French AngoraOP
oh well wait i fixed the redirects
using local ssl the redirects work
however they do not work anymore once port forewarded
Oh, what's the issue?
French AngoraOP
i don't actually know
it dosen't even connect
now i set the port forwarding again and it gives me another error ahahah
before it was like: Response is empty
now it's the can't reach
well at least
my local problem is fixed
i will just have the constraint to the guy using it that it will require him to be connected to the wifi
now i have to hit my head against the router to enable port forwarding
French AngoraOP
Well checked with another device the local-ssl-proxy is really local ahahah
does not work with any other device in the network
I usually avoid using https on localhost. It's a hassle to set up and it sometimes doesn't even work as expected. Browsers are smart enough these days to allow secure context on local host too