aws cdn字体跨域问题
程序员文章站
2022-05-21 10:42:54
...
1: 首先设置nginx服务器支持跨域,如下
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
2:打开aws的cdn,选择源,进行编辑,在底部 "源自定义标头标头名称"添加如下内容:
Access-Control-Allow-Methods GET
Access-Control-Allow-Origin *
3: 选择行为,编辑
1)"允许的 HTTP 方法" "GET、HEAD、OPTIONS"
2) "缓存的 HTTP 方法" "OPTIONS"
3) "基于选择的请求标头进行缓存白" 白名单
4)"白名单标头" Origin
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
2:打开aws的cdn,选择源,进行编辑,在底部 "源自定义标头标头名称"添加如下内容:
Access-Control-Allow-Methods GET
Access-Control-Allow-Origin *
3: 选择行为,编辑
1)"允许的 HTTP 方法" "GET、HEAD、OPTIONS"
2) "缓存的 HTTP 方法" "OPTIONS"
3) "基于选择的请求标头进行缓存白" 白名单
4)"白名单标头" Origin
上一篇: NodeJS实现不可逆加密与密码保存
下一篇: map和forEach兼容ie6-8方法
推荐阅读