Search code examples
angularangular6angular7

Angular - <base href="/projectname/client"> in index.html throwing an error


My application is in Angular 7 deployed on Openshift with Docker image. I want my application url to be like https://ocp-1123/projectname/client , when i tried to set my base href with "/projectname/client" it throws errors as in picture. enter image description here

But when I set my base href with "/projectname" or just "/" , it works perfectly fine. I am not sure if there is any restriction of usage of multiple path context in base href..? Please suggest .

Thank you.


Solution

  • You need an additional / in the end:

    <base href="/projectname/client/">
    

    as per the doc:

    But on the shared or production server, you might serve the app from a subfolder. For example, when the URL to load the app is something like http://example.com/my/app/, the subfolder is my/app/ and you should add <base href="/my/app/"> to the server version of the index.html.