nginx 跨域问题

nginx 跨域问题

跨域问题有两种解决方法,

  • 让开发自己修改代码解决跨域问题
  • 修改nginx配置解决跨域问题

这里是记录了nginx的解决方式
后端服务调用报错跨域问题,为解决跨域问题,在网上搜索一大坨跨域解决方案,可以先都粘过去,后面慢慢删挑选正确的跨域问题

		proxy_set_header Cookie $http_cookie;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "Upgrade";
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_hide_header X-Frame-Options;
		add_header X-Frame-Options ALLOWALL;
		add_header Access-Control-Allow-Origin *; 
		add_header Access-Control-Allow-Headers *; 
		proxy_cookie_domain remote localhost;  
		add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
		ignore_invalid_headers off;
		proxy_set_header Host $host;
		real_ip_recursive on;
		keepalive_timeout  65;
posted @ 2022-09-26 20:40  liwenchao1995  阅读(56)  评论(0编辑  收藏  举报