CSP in Umbraco 12 CMS
# help-with-umbraco
j
Is there a way to remove the CSP from the Umbraco CMS but keep the front end in IIS - using umbraco 12? We don't want to use a Third Party Package. Thanks Jon
c
Hi @jonroberts if you are hosting Umbraco in Windows you can still use a web.config file and add the necessary block inside a location path for /umbraco.
Or in the Configure method in your Startup.cs file you could do something like this and alter the header for CSP. This is a different example but you should get the idea:
Copy code
cs
        app.UseWhen(
            context => !context.Request.Path.StartsWithSegments("/umbraco")
            && !context.Request.Path.StartsWithSegments("/media"),
            appBuilder => appBuilder.UseStaticFiles(new StaticFileOptions
            {
                OnPrepareResponse = ctx =>
                {
                    var cacheMaxAgeThirtyDays = (60 * 60 * 24 * 30).ToString();
                    ctx.Context.Response.Headers[HeaderNames.CacheControl] =
                        "public, max-age=" + cacheMaxAgeThirtyDays;
                }
            })
        );
j
Great - thank you so much for this
Hi @CodeSharePaul - Can I ask - is there a Content Resolver for the Umbraco 12 CMS? There is a Media Resolver but we need a content one - so we can get content out of a UDI
c
How do you mean @jonroberts ?
So you have a UDI and you want to get the content item from it. Is that right?
j
Yes 🙂
In Angular JS
A bit like - {{mediaItem = (block.data.image[0].mediaKey | mediaItemResolver); ""}} But for content instead
c
Oh right, I'm not sure about that, sorry
You could look at the code for the mediaItemResolver filter and create your own contentItemResolver filter
j
Do you know where the mediaItemResolver is - I have searched for the code in 12 and can't find it
j
Brilliant - thank you so much
12 Views