Closed daemons88 closed 2 months ago
You only need to specify the APP_BASE_HREF
if it differs from the one set in index.html
. When using localization, the locale is added to the baseHref
option. For instance, /staffing
becomes /staffing/es
for the Spanish version of the application.
However, based on your comments, it seems this issue is related to an NGINX configuration.
Please note that this issue tracker is not intended for support requests. Kindly repost your query on StackOverflow using the angular-cli
tag.
If you're curious why support issues aren't handled through the issue tracker, please refer to this explanation.
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.
Which @angular/* package(s) are the source of the bug?
localize
Is this a regression?
No
Description
I have been trying to solve this problem for several days, additionally, it is the first time I am using localization in Angular, so it might be a matter of unfamiliarity. Now, let me explain my issue:
In my application, before adding localization, I was using a base href -> staffing which I have configured as follows in the following files:
angular.json "baseHref": "/staffing/"
index.html
main.ts bootstrapApplication(AppComponent, { providers: [ { provide: APP_BASE_HREF, useValue: '/staffing' }, ..... ], }).catch(err => console.error(err));
and it was working like a charm with all the urls using http://localhost:4200/staffing/....
Now I add localization 'en' and 'es', and this as you know generates two builds folders dist/app-name/en and es. From the deploy point of view, I have to change the configuration, I had before angularapp folder and now angularapp/es and angularapp/en I changed the location path in nginx and started receiving this error.
polyfills.9e8d107e6201c474.js/:1 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
So I think maybe there is a problem in the configuration of ngixn and I believe that for a while until I can reproduce the issue locally.
I changed the base href just for testing purposes to this (with this path is how was generated to production):
angular.json "baseHref": "/staffing/es"
index.html
main.ts bootstrapApplication(AppComponent, { providers: [ { provide: APP_BASE_HREF, useValue: '/staffing/es' }, ..... ], }).catch(err => console.error(err));
and now in my local, I have this error and the page is not loading like in the server: Refused to apply style from 'http://localhost:4200/staffing/styles.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
Is there an extra configuration I need to do to make this work?
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
here is the angular.json configuration: