How can I serve Angular 4 localhost to ngrok?

Viewed 12034

I would like to use ngrok to make my local development available to external apis that need to use webhooks with it but when I run ngrok on port 4200, Angular gives me Invalid Host Header when I try to access the site from the ngrok link. Does anyone know how I can access an angular ng serve from outside localhost with ngrok?

Thanks

5 Answers

I tried running the ng serve on prod environment by disabling the host check option and it worked,

Cmd1:

ng serve --prod --host 0.0.0.0 --disable-host-check. and tried using ngrok with the following solution

Cmd2:

ngrok http 4200 -host-header="localhost:4200"

This works with single line code:

ngrok http 4200 -host-header="localhost:4200"

It's working, but it throw error Invalid Host/Origin header + [WDS] Disconnected! in console...

Small reminder, an issue I was facing myself. For me, the solution of Diego Santa Cruz MendezĂș worked. But it only worked for me in my Google Chrome 'Incognito' browser because then all my extensions are disabled! Just a reminder that a console error can also be an extension error and therefore the site might not show up (correctly), which was the case at my side.

Related