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

Nested roots not working using the browser`s adress bar #3517

Closed
MiroKov opened this issue Dec 11, 2016 · 4 comments
Closed

Nested roots not working using the browser`s adress bar #3517

MiroKov opened this issue Dec 11, 2016 · 4 comments

Comments

@MiroKov
Copy link

MiroKov commented Dec 11, 2016

OS?

Windows 10.

Versions.

angular-cli: 1.0.0-beta.22-1
node: 6.9.2
os: win32 x64

Repro steps.

Created an app using ng new. Pasted und updated my code that worked before using angular-CLI so that there are no more errors.

The log given by the failure.

The app compiles fine. The error is in Chrome, when using refreshing the webpage from the browser:

Uncaught SyntaxError: Unexpected token <

response is:
grafik

Mention any other details that might be useful.

My application uses an MVC server-side routing that points to ~/index.html.
Index.html looks like this:

<title>Title</title> Loading... <script type="text/javascript" src="inline.d41d8cd98f00b204e980.bundle.js"></script>
<script type="text/javascript" src="styles.5f7f16a82a4f91544984.bundle.js"></script>
<script type="text/javascript" src="scripts.4cc5cca4ad2b0c20ad9d.bundle.js"></script>
<script type="text/javascript" src="vendor.bdd774df3cfec44bf929.bundle.js"></script>
<script type="text/javascript" src="main.b68070036956df1649d5.bundle.js"></script>

Scripts mentioned live in the same directory as index.html. The thing is, as soon as I change the directory by nesting roots
(by adding a one more '/' -> for instance when I change http://myApp/accounts to http://myApp/accounts/)
,I get the errors mentioned. Just to be explicit, routing within angular2 works good, the problem is when the request comes from browser/server.
Then I need to put something in the index.html, for instance:

<script type="text/javascript" src="**../**inline.d41d8cd98f00b204e980.bundle.js"></script> in order to get the script loaded, but naturally, the routes no longer work, and would ve a solution just for this depth of the application, when it would work. But at least it seems to point where the problem is, namely changing the directory seems to cause the problem.
@clydin
Copy link
Member

clydin commented Dec 11, 2016

It looks like your base href is the issue. Try setting it to '/'.

@MiroKov
Copy link
Author

MiroKov commented Dec 11, 2016

Thank you. You have saved me weeks...

@MiroKov MiroKov closed this as completed Dec 11, 2016
@MiroKov MiroKov reopened this Dec 12, 2016
@MiroKov MiroKov closed this as completed Dec 12, 2016
@MiroKov
Copy link
Author

MiroKov commented Dec 12, 2016

Found the culprit:

declare var __webpack_public_path__: any;
__webpack_public_path__='http://localhost:54276/dist/';

@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
None yet
Projects
None yet
Development

No branches or pull requests

2 participants