0

I'm on a Mac and I've got an Angular app running locally on this url: http://localhost:{port}/myPage.html

Now I've got a Windows HVD and I'm trying to access that same site so I substitute localhost with my IP but all the files it tries to load comes back with this error:

Invalid host header 

So, this happens for all bundled files. Here's the request that returns the invalid host header error:

Request URL: http://{myIp}:{port}/myBundledFile.js 

My build script runs a server that I have configured (based off web pack) and I'm guessing that might be the problem:

"concurrently \"ng serve -c es5 --host=0.0.0.0\" \"npm run my-dummy-server\"" 

I guess that I don't know exactly what might be causing the problem because I should be easily able to hit my HOST machine from my HVD.

1 Answer 1

2

try this: add --disable-host-check param

"concurrently \"ng serve -c es5 --host=0.0.0.0 --disable-host-check\" \"npm run demo-server\"" 

by default webpack server doesn't allow connections from other hosts as it could be a security issue

Sign up to request clarification or add additional context in comments.

3 Comments

Wow, this totally loads all the files!! And I'm going to accept this answer, but if you have time for one more question. The demo server I'm running is pulling dummy data from localhost still: Request URL: localhost:4201/api/success/… . I guess I've got to find where that localhost is configured in the demo server code.
usually you have some constant like API_URL in the configuration of your project, you add this url to your app requests and it would work
worked like a charm. you're a lifesaver, thank you so much.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.