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.


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.


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 –disableHostCheck true

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

Leave a Reply

Close Menu