Next.js Discord

Discord Forum

Mocking HTTPS and URL

Answered
David L. Bowman posted this in #help-forum
Open in Discord
Avatar
I'm working with some APIs which require me to mock an HTTPs and actual url, they reject :3000 or whatever. What's the best way for me to get this working so I can test in a dev environment.
Answered by David L. Bowman
@iyxan23 & @Havana , i was able to solve the problem by following these steps:

1. creating an ngrok account.
2. running: ngrok config add-authtoken ${authToken}
3. running: ngrok http --domain=${ngrokUrl}.app 3000
4. changed package.json dev script to next dev --experimental-https
View full answer

28 Replies

Avatar
so essentially you need an HTTPS endpoint that tunnels to your localhost dev server?
oh hey david didn't notice it was you lol
Avatar
Hey 😄
I actually figured out the HTTPS part, but now i'm trying to get it to go to something like https://example.com but that actually be my localhost env.
the issue is authorize.net doesn't let me test on localhost, and i dont' want to push to a static staging url everytime i make a chagne.
Avatar
is it for webhook notifications? or something?
Avatar
it's for a redirect, it's very annoying
Avatar
also what test are you trying to do with authorize.net?
oh its just a redirect
Avatar
i wonder if i just change to port 80
Avatar
Havana
What about using ngrok?
It will port forward from 80 or 443 (not sure), to the local 3000
The only issue is that the generated link will always change when you restart the ngrok
Avatar
mm yeah that could work
Avatar
Havana
Thats the purpose of port forwarding
Forwarding from an external port that somebody wants to access, to a local port
So if you use it anywhere, you will always have to change it, kind of annoying
Or you could buy VPS/VDS, and then use nginx
Avatar
decent enough for testing
Avatar
Havana
Sure
Avatar
since it's for a redirect, booting up a simple github pages with just <script>window.href = "localhost:3000/";</script> might work lol
Avatar
Havana
ofc
just change the link to the ngrok link
That's how I tested, it works both in dev and prod modes
Avatar
i could try that.
Avatar
@iyxan23 & @Havana , i was able to solve the problem by following these steps:

1. creating an ngrok account.
2. running: ngrok config add-authtoken ${authToken}
3. running: ngrok http --domain=${ngrokUrl}.app 3000
4. changed package.json dev script to next dev --experimental-https
Answer
Avatar
Havana
Good job
Glad I could help