欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

aws cdn字体跨域问题

程序员文章站 2022-05-21 10:46:28
...
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



相关标签: asw cdn