简体   繁体   中英

set access-control-allow-origin response header only for static files in IIS

I'm using IIS to serve static files and also to send API requests to a python backend server. for API requests the backend correctly sets CORS-related headers but for static files, I get errors. additionally, I can't set these in Response Headers in IIS because it conflicts with those set with the backend app. So is there any way in IIS to check if some certain header is empty or requested response is a file or even check URI for a pattern like /static/ and then modify the response header? I've reached to URLRewrite so far but I doubt it could modify the header.

after a little bit of digging it turned out you can set Response Header specific to each directory. so I set the CORS-related headers in my ./static/ sub-directories and it works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM