Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

base href conflict #646

Closed
ghost opened this issue May 5, 2016 · 5 comments · May be fixed by luke7oaks/angular-cli#95
Closed

base href conflict #646

ghost opened this issue May 5, 2016 · 5 comments · May be fixed by luke7oaks/angular-cli#95
Assignees
Labels
effort2: medium (days) P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@ghost
Copy link

ghost commented May 5, 2016

Please, create base href replacement optionally.

@hansl hansl added effort2: medium (days) command: serve P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent labels May 6, 2016
@simon-sharp
Copy link

simon-sharp commented May 12, 2016

Solution:

Replace
<base href="/">
with
<script>document.write('<base href="' + document.location + '" />');</script>
in
angular-cli\addon\ng2\blueprints\ng2\files\__path__\index.html

@ghost
Copy link
Author

ghost commented May 12, 2016

Thanks. I solved this problem by:

import {APP_BASE_HREF} from '@angular/common';

bootstrap(AppComponent, [
  ROUTER_PROVIDERS, 
  provide(APP_BASE_HREF, {useValue : '/' });
]); 

@filipesilva
Copy link
Contributor

Closing in favor of #1064, which is more explicit.

@niklas-dahl
Copy link
Contributor

@fdhadzh I tried your solution but it only works for routes like this: localhost:4200/xxx.
The moment the route is one "layer" deeper it doenst work: localhost:4200/xxx/yyy or just localhost:4200/xxx/ (second slash).

This is because without a base tag the generated script tags no longer refer relative to /:

<script type="text/javascript" src="inline.bundle.js"></script>
<script type="text/javascript" src="styles.bundle.js"></script>
<script type="text/javascript" src="scripts.bundle.js"></script>
<script type="text/javascript" src="vendor.bundle.js"></script>
<script type="text/javascript" src="main.bundle.js"></script>

I want to use svg markers that require relative FuncIRIs.

@filipesilva Is this currently solvable with the current webpack setup?

Thanks.

Problem described here:
https://stacksandfoundations.com/2016/06/22/svgs-funciri-angular2-and-the-base-tag/

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
effort2: medium (days) P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants