Nginx 跨域
2024-09-30 11:58:49
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
#
# Custom headers and headers various browsers *should* be OK with but aren't
#
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
#
# Tell client that this pre-flight info is valid for 20 days
#
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 = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
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,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
} }
最新文章
- [.NET领域驱动设计实战系列]专题六:DDD实践案例:网上书店订单功能的实现
- leetcode-Combinations 复习复习排列组合
- float 在内存中如何存储的
- Maven简介
- 在centos7中限制kvm虚拟机可访问的资源
- php中的修饰符
- 小结OC中Retain cycle(循环引用)
- 根据list<;Object>;中的某个字段排序
- C++知识点整理——持续更新
- A Byte of Python 笔记(4)控制流:if、for、while、break、continue
- C# 8.0的三个令人兴奋的新特性
- Vue components Cannot read property &#39;__ob__&#39; of undefined
- C++进阶:新人易入的那些坑 --1.常量、常指针和指针常量
- 【Java并发.4】对象的组合
- HTTP响应过程
- Golang依赖管理工具:glide从入门到精通使用
- webpack打包二进制文件报错
- pyqt5界面切换
- [bzoj 4196][NOI 2015]软件包管理器
- 【转】Entity Framework教程(第二版)