Created
January 15, 2021 23:42
-
-
Save ajtatum/f920fc392de2bdaeaf5184277b1fd5ca to your computer and use it in GitHub Desktop.
ImageKit Client Hints
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var imageCdnUrl = Configuration["CDN:Images:CdnUrl"]; | |
app.Use(async (context, next) => | |
{ | |
context.Response.Headers.Add("Accept-CH", "viewport-width, width, dpr"); | |
context.Response.Headers.Add("Feature-Policy", $"ch-viewport-width {imageCdnUrl};ch-width {imageCdnUrl};ch-dpr {imageCdnUrl};ch-device-memory {imageCdnUrl};ch-rtt {imageCdnUrl};ch-ect {imageCdnUrl};ch-downlink {imageCdnUrl}"); | |
context.Response.Headers.Add("Permissions-Policy", $"ch-viewport-width {imageCdnUrl};ch-width {imageCdnUrl};ch-dpr {imageCdnUrl};ch-device-memory {imageCdnUrl};ch-rtt {imageCdnUrl};ch-ect {imageCdnUrl};ch-downlink {imageCdnUrl}"); | |
await next(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment