介绍

  • 头添加 Access-Control-Allow-OriginAccess-Control-Allow-MethodsAccess-Control-Allow-Credentials

指令

  • addheader | Syntax: | **add_header**_name`_value_ [always];| | :--- | --- | | Default: | — | | Context: |http,server,location,if in location` |

    • name 设置为 Access-Control-Allow-Origin , value 为跨域网址
    • name 设置为 Access-Control-Allow-Methods,value 设置支持的 http methods,比如 GET, POST, PUT, DELETE, OPTIONS
    • name 设置为 Access-Control-Allow-Credentials, value 设置为 true