-
Notifications
You must be signed in to change notification settings - Fork 12k
Incorrect JS paths when ng build -prod is deployed in a subfolder #1080
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
Comments
When you're deploying to non-root path within a domain, you'll need to manually update the In this case, you will need to update to |
Thanks for your answer @filipesilva , that fixes the issue! Sorry I didn't notice the base tag. |
Don't be sorry, this is a common scenario and not so easy to identify. Next time someone has the same problem they will find your issue :) |
It worked for me to deploy in my production server, but after change, 'ng serve' doesn't load application anymore either in http://localhost:4200/myfolder or in http://localhost:4200 paths. Is there any way of making this change automatically depending on prod/dev execution mode? Thanks in advance! |
@JavierFuentes it doesn't make sense to use |
@filipesilva You give me a clue... You can view the result here: http://foobar.cf/calculator Thanks a lot! |
@filipesilva I think @JavierFuentes idea of hosting the app while development within another subdirectory makes sense in a specific context. See my new issue #3010 therefore. I'd appreciate your opinion on it. |
Hi , I have a similar issue. I have deployed Angular 2 inside War file in tomcat. I have changed base href to "/AngularSpring" in index.html. http://localhost:8080/AngularSpring/---- . Application URL. The application is loading fine but resources which are inside asset folder gives 404. please help I have N number of the solution but none of them worked. I don't want to change the path in the file manually. |
I am having same issue, |
try ng build --prod --aot=false -bh /myfolder -d /myfolder |
@@thanks Chandresh! |
are you setting welcome file list as index.html in web.xml ? |
Thanks, that worked, but the Spring security is blocking it, |
don't give the root to pass through the spring controller. |
@filipesilva , Its showing me the 404 error. Any other way for solution? Please share. Thanks |
@ShaadH you need to configure your server to fallback to |
Having the same issue as @chandresh87 - |
@itaysk you'll have to set |
@filipesilva there's no |
@itaysk apologies, it's |
@filipesilva adding |
Hey, I am trying to host a static page on github pages. using All the js and css load up fine but assets give 404. Angular tried to find assets at |
Solved the issue using |
Updating the base href works but when I refresh the page, I get 404 |
@simonatorw |
@filipesilva I am facing similar issue, while running ng build command it is deleting dist folder. Angular CLI: 1.6.6 @angular/cli: 1.6.6 the error is... chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered] ERROR in TypeError: Cannot read property 'loadChildren' of undefined |
developers typically (at least I do for convenience and just to have a tomcat server running with ability to go there and launch any project of convenience from anywhere from home office or mobile phone) develop a project off of tomcat root here is the path angular-cli bundles and builds out to
I run my tomcat on 8080 app runs but paths to assets and bundles are frigged I am seeing (depending on what we set href to) paths ahead or after resulting in inaccessible paths to bundles and assets. currently my app runs but cannot retrieve assets no matter what I try currently if I set if I set ??? |
Saved my day. |
Is there a way to avoid setting the base-href in the ng build? |
@filipesilva you're brighter then a brain pie! Thank you so much - Was troubleshooting my Node Express + Angular6 app and for the life of me couldn't figure out why |
Github!! Code Savers thanks @filipesilva |
@filipesilva your solution saved me. Thanks a lot!! |
Am getting the same issue of following all the assets folder taking Versions are: Package Version@angular-devkit/architect 0.6.8 |
yeah its working but when i refresh a page then through page not found error |
For anyone still having issues with assets, you should reference your images etc using a relative path e.g "./assets/image-1.png". This resolved my issue. |
I can confirm what @tyronboyd said. Nr 1: Change index.html default Nr 2: You can run: Nr 3: You can change your build process, found in angular.json, to automate this by adding: Obviously you can use fixed paths as well with either of these, but adding this single dot to the default uses relative paths, which I would guess is the default behavior one would expect. |
@MarcoHeumann had a similar issue fixed it by changing the index.html default to was wondering how does the absolute and relative path referencing make the difference. Can you help understand ? Appreciate your help in advance ! |
To understand this, I urge you to just look at the error when you don't do the change. Basically the absolute path is wrong, like all the time, while making it relative gives you full control over your structure, while also working as expected. We have come to expect relative paths everywhere and that is for a reason, but a reason Angular does not seem to follow. |
Hello, I tried all the solutions but to no avail. My Angular and Backend application both are packaged in one jar. So, is that the reason it is not working or something else.? |
@MarcoHeumann but that would introduce the problem in reloading the page. Because when reloading it uses the current path as the base path. |
This will work <script>document.write('');</script> |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
angular-cli: 1.0.0-beta.5
node: 4.4.5
os: win32 x64
Browser log when accessing http://datamatic.co/angular2-test/:
Files are loaded relative to the domain, not the folder
The text was updated successfully, but these errors were encountered: