File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -23,9 +23,23 @@ public override void Configure(Container container)
2323
2424 SetConfig ( new HostConfig {
2525 IgnorePathInfoPrefixes = { "/appsettings" , "/_framework" } ,
26- GlobalResponseHeaders = {
27- { "X-Frame-Options" , "SAMEORIGIN" } ,
28- } ,
26+ } ) ;
27+
28+ string [ ] allowedOrigins = [
29+ "https://localhost:5001" ,
30+ "https://localhost:5002" ,
31+ "https://docs.servicestack.net" ,
32+ "https://servicestack.net" ,
33+ "https://*.servicestack.net" ,
34+ ] ;
35+
36+ GlobalResponseFilters . Add ( ( req , res , dto ) => {
37+ var origin = req . Headers . Get ( HttpHeaders . Origin ) ;
38+ if ( origin != null && allowedOrigins . Any ( o => origin . StartsWith ( o ) ) )
39+ {
40+ res . AddHeader ( "X-Frame-Options" , $ "ALLOW-FROM { origin } ") ;
41+ res . AddHeader ( "Content-Security-Policy" , $ "frame-ancestors { origin } ") ;
42+ }
2943 } ) ;
3044 }
3145}
You can’t perform that action at this time.
0 commit comments