Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· OpenAIAi2 WildChat-4.8M (AI2)

如果我配置了 location / { add_header Access-Control-Allow-Origin *; addheader…

  1. User

    如果我配置了 location / {
    add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS'; add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';

    if ($request_method = 'OPTIONS') {
        return 204;
    }
    

    }

    那么其他的配置项,例如 location /api { ... } ,是否也是允许跨域的?

  2. Assistant

    是的,如果在 "/api" 的 location 配置中没有特别限制跨域访问的话,那么也会遵循全局的跨域设置。