-
Notifications
You must be signed in to change notification settings - Fork 12k
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
With modified deploy-url, inlining critical css not working for downloaded roboto font #22208
Comments
Can you please provide the values of deployUrl and baseHref options? |
@alan-agius4, Yes I have mentioned it in the description under package.json
Observation here is, when I set inlineCritical to |
Hi @school-coder, I managed to replicate this. However, it's important to point out the Since this is not a regression I am inclined to say that we shouldn't be fixing deprecated behaviour unless it's a regression especially considering that this issue is not a problem when migrate to the recommended alternative for |
@alan-agius4 : I am still not clear why In my case, static assets needs to be load from In our case, we are doing white-listing the security for the path having What would be your recommendation in this case? Note: I am also following the issue #22113 on the same usecase |
@school-coder, You don't need You can set the More info about the deprecation can be found here: #21537. |
@alan-agius4, I tried the steps you have followed which resulted in,
generated in For example, Expected: But the request triggered as, |
No they are 2 different settings although when The |
Yes, that's exatcly what I have experienced when trying to use I have ended up with an interceptor, but not 100% satisfying IMO. import { HTTP_INTERCEPTORS, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { ExistingProvider, Injectable } from '@angular/core';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class BasehrefInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
if (!req.url.toLocaleLowerCase().startsWith('http')) {
const dupReq = req.clone({ url: `../${req.url}` });
return next.handle(dupReq);
}
return next.handle(req);
}
}
export const BasehrefInterceptorProvider: ExistingProvider[] = [{
provide: HTTP_INTERCEPTORS,
useExisting: BasehrefInterceptor,
multi: true
}] |
@mpalourdio +1 |
Also there's a problem I think when using the dev server. (I was just testing in build prod mode for the moment) Imagine you configure this in dev mode to handle this use case.
and this, as @alan-agius4 said it's supposed to work now: Now, go to http://localhost:4200/my-context/path/ => 404. That's wrong, as it's supposed to be the router base as stated by the Ok, so let's go to http://localhost:4200/my-context/path/static/ : redirects to http://localhost:4200/my-context/path/ and it works this time... Refresh the page : 404 |
Exactly, facing the same with the dev server after following the suggestion. @alan-agius4 : IMO, the alternative you have provided doesnt solve the use-case. |
@school-coder, currently, what are the deployUrl and baseHref configuration that you use for the dev-server? Let me explain why the above errors and why they are happening:
During development The dev-server, is a minimal server that doesn't offer all the functionality that a production server has. |
Yes, I understand why those 404 happen, of course. But, when removing And as you can see in my example, both Also navigating to |
During development you can also set, Some of the drawbacks of
|
@mpalourdio and @alan-agius4 : I have couple of updates Update 1: Adaption of suggestion is now workingMy Environment: baseHref='/portal/public/' Adaption i have done,
Dev Server and Production Server working fine now. I need not to do any change specific to dev server. For example removing APP_BASE_HREF, Only thing, I need to adapt static urls used through out the application. for example, I need to adapt the url Update 2: Enabling inlineCritical generates right URL now.After configurating inlineCritical as Update 3: Content Security Policy Issue while enabling inlineCritical.I doubt it is related to the generated link element,
As this link element is generated during the build, adding Is there anyway to resolve this? My Current Content Security Policy,
|
The CSP issue is a known limitation which is being tracked here: #20864 |
@alan-agius4 @school-coder I think I have made it work as desired too (The interceptor is indeed really needed, and injecting the I suspect this will pop again and again on this tracker once Once again, thanks ! And keep-up the good work angular team, you do an awesome job! |
Glad to hear that the issue is solved by not using |
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. |
🐞 With modified deploy-url, inlining critical css not working for downloaded roboto font
Command (mark with an
x
)Is this a regression?
No.
In v12 also, was not working.
Description
A clear and concise description of the problem...🔬 Minimal Reproduction
With modified deploy-url, inlining critical css not working for downloaded roboto font
package.json
font.css
angular.json
projects..architect.build:
🔥 Exception or Error
the path is http://localhost:8080/portal/Roboto-Light.86fc2559ff73eac5.woff2 instead of http://localhost:8080/portal/public/Roboto-Light.86fc2559ff73eac5.woff2
🌍 Your Environment
13.0.0
The text was updated successfully, but these errors were encountered: