Senario

You are creating an Angular 2+ Application that uses Login With Amazon (LWA)

So that you can test locally, you are using ngrok and have setup an ngrok https address as the return URL at LWA

When Amazon sends you back to your application after a successful login, , you get an “Invalid Host Header” error.

Why?

The reason for the error is that most development-oriented application servers (such as ng, webpack-dev-server, or WAMPP) default to only binding to localhost. As a result, only traffic directed to your machine from itself is allowed to pass through. This means that that traffic passing through the ngrok tunnel will not work the same as traffic coming from your machine directly.

Solution

To get around the issue, in most cases, the fix is to tell the server to restart and allow connections from outside localhost.

So for your Angular 2+ Application you would start like this

ng serve –host 0.0.0.0 –disableHostCheck true

Once the server starts, run the Application and there should be no ‘Invalid Host Header’ error

Leave a Reply

Close Menu