Hi,
We created a new project. We didn't make any changes.
Angular client returns "Cannot GET /"
In console we get the following error :
Content-Security-Policy: The page’s settings blocked the loading of a resource (img-src) at http://localhost:4200/favicon.ico because it violates the following directive: “default-src 'none'”
Thanks,
11 Answer(s)
-
0
To resolve the Content-Security-Policy (CSP) error blocking image loading (such as favicon.ico) in your ABP Angular project, you need to adjust the CSP headers to allow images from the required sources.
By default, ABP's Security Header Middleware may set a restrictive CSP like
default-src 'none', which blocks all resources unless explicitly allowed. This causes the browser to block images, including the favicon.Solution:
Locate the CSP configuration in your server-side (API or host) project. This is typically set in the
ConfigureServicesorOnApplicationInitializationmethod, or in theappsettings.jsonunderSecurityHeaders.Update the CSP to allow images from your domain. For example, in C#:
app.UseAbpSecurityHeaders(options => { options.ContentSecurityPolicy = "default-src 'self'; img-src 'self' data:;"; });'self'allows images from the same origin.data:allows inline images (such as base64-encoded favicons).
- If you are using
appsettings.jsonfor configuration, update the relevant section:
"SecurityHeaders": { "ContentSecurityPolicy": "default-src 'self'; img-src 'self' data:;" }- Restart your application after making these changes.
This will resolve the error and allow the favicon and other images to load.
Sources:
- https://abp.io/docs/latest/framework/ui/mvc-razor-pages/security-headers
- https://abp.io/docs/latest/others/penetration-test-report
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
I tried removing app.UseAbpSecurityHeaders();
I also tried adding the following in ConfigureServices :
Configure<AbpSecurityHeadersOptions>(options => { options.UseContentSecurityPolicyHeader = true; options.ContentSecurityPolicyValue = "default-src 'self'; img-src 'self' data:;";
});Neither worked.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
hi
Do you also have this error message in your Chrome console?
Refused to connect to 'http://localhost:4200/.well-known/appspecific/com.chrome.devtools.json' because it violates the following Content Security Policy directive: "default-src 'none'". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
[maliming] said: hi
in my personal case I DO get that error and I don't know what to do :(
Regards
Do you also have this error message in your Chrome console?
Refused to connect to 'http://localhost:4200/.well-known/appspecific/com.chrome.devtools.json' because it violates the following Content Security Policy directive: "default-src 'none'". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hello,
We have identified the same problem on our side. I can recommend you to migrate to the new application builder using this command:
yarn ng update @angular/cli --name use-application-builderHere is the official reference: https://angular.dev/tools/cli/build-system-migration#automated-migration-recommended
After that, you need to remove the paths inside the
tsconfig.jsonfile{ "compileOnSave": false, "compilerOptions": { "baseUrl": "./", "outDir": "./dist/out-tsc", "sourceMap": true, "declaration": false, "downlevelIteration": true, "experimentalDecorators": true, "moduleResolution": "node", "importHelpers": true, "target": "ES2022", "module": "es2020", "lib": ["es2018", "dom"], "paths": { }, "useDefineForClassFields": false }, "angularCompilerOptions": { "enableI18nLegacyMessageIdFormat": false } }You can also use the es build for the localization registration inside
app.config.tsimport { registerLocaleForEsBuild } from '@abp/ng.core/locale'; export const appConfig: ApplicationConfig = { providers: [ //... provideAbpCore( withOptions({ environment, registerLocaleFn: registerLocaleForEsBuild(), }) ), //... ], };I will also be processing a refund for your ticket. Thank you for your cooperation.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)