2

I've created a fresh Angular project, and I built it with ng build. Then I copied it to c:\inetpub\wwwroot\MyProject\. I've added it using "Convert to Application" in IIS Manager.

enter image description here

I then browse it, using http://localhost:81/MyProject/, but all subsequent requests made by Angular fail because they lack the /MyProject at the root. For example, from the tooltip, it tries to load inline.bundle.js from http://localhost:81/inline.bundle.js/ instead of http://localhost:81/MyProject/inline.bundle.js/

enter image description here

How can I make it take into account the root MyProject?

1
  • Try researching about the web.config file. If I'm not mistaking, you can use that to rewrite all requests to the path you wish. I had to do it to deploy to Azure Commented Mar 23, 2018 at 14:30

1 Answer 1

2

Change the <base href> property to point to your sub directory ("MyProject") in the new app's index.html (or default page).

Example:

<base href="/MyProject/">

Or, for a more directory-agnostic, relative path approach (provided by the OP)

<base href="./"> 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! This led me to the right direction, but I used <base href="./"> instead, since that will work regardless of the name under which I deploy the site. There already was <base href="/">, I just needed to add a dot in front.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.