Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 4 ng build base-href duplicate subdirectory

I'm deploying builds of my angular app to an s3 bucket with different subdirectories based on the branch name. The urls look like:

pr.example.com/add-cool-spinner
pr.example.com/increase-awesomeness

If I deploy using --base-href /add-cool-spinner it properly updates the base tag: <base href="add-cool-spinner">. However when redirecting or generating links the subdirectory doubles, so link tags generated from the router look like:

pr.example.com/add-cool-spinner/add-cool-spinner/page

I've tried changing only --deploy-url instead, but then it doesn't update the base href tag, and references root url (pr.example.com/page).

Have any hints for not doubling up the base url directory? Is this a bug or did I do something wrong?

like image 817
Will Shaver Avatar asked Oct 09 '17 20:10

Will Shaver


1 Answers

Turns out that this isn't super well documented, but angular is expecting a proceeding and trailing slash. So deploy with:

ng build --base-href /add-cool-spinner/

It still isn't referencing images correctly that are in image tags, and that might be because of known bugs in the builder.

like image 170
Will Shaver Avatar answered Sep 19 '22 13:09

Will Shaver