This repository has been archived by the owner on Oct 14, 2024. It is now read-only.
Serving static content based on Angular's BASE_HREF #567
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem: I was unable to serve my static content when I published my app under a subpath route like
mydomain.com/myapp/*
.Result: In this PR I created a way to dynamically get the base route of my application (stored in the
BASE_HREF
constant). How: I look intoindex.html
file at runtime and do extract the<base href="X">
tag's value. Then, instead of using'*.*'
, I use that value to create my static content route. Now I'm able to publish my application in multiple environments (e.g. development, homolog, production) with just changing the--base-href
value in build configuration time.Got help from @andrevargas.