当前位置:网站首页>Record of a cross domain problem
Record of a cross domain problem
2022-07-27 10:44:00 【Die hard audio and video】
Preface
Last project , For some reason , Need from https Access changed to http visit , There are cross domain problems in the transformation , Record... Here .
Project use nginx Acting as a reverse agent .
reform HTTP
When you visit the website browser, you will automatically jump to https, Need to put nginx http Redirect to https It's annotated
server { listen 80; listen [::]:80; server_name server_name; location ^~ /.well-known/acme-challenge/ { default_type "text/plain"; root /usr/share/; } location = /.well-known/acme-challenge/ { return 404; } # location / { # return 301 https://$host$request_uri; # }}So when we visit the browser , Will not automatically redirect us to https
Cross domain
It's changed to http Cross domain occurs when , The general solution is to nginx Add the following configuration
add_header 'Access-Control-Allow-Origin' '*';But we also made the following mistakes
from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
This error means that during the pre inspection , The browser does not allow redirection .
We see the MDN Definition of cross domain
Cross domain is actually a protection of browser access to different domains , Otherwise, anyone can access the resources of your domain name at will , It's also terrifying
In the case of not simple requests , Browsers usually publish one options Pre inspection request , To know if the server allows the actual request ." Pre inspection request “ Use , It can avoid the unexpected impact of cross domain requests on the user data of the server .
This design is very humanized , You can't add it directly to your business request ?
Back to our question , During the pre inspection , Redirection is not allowed , But my address is not redirected , Is something secretly giving me a layer of redirection behind my back ?
Request link : browser --》nginx--》 Business
Business is definitely not redirected , Browsers will not redirect for no reason , Then only NGINX 了
Open the browser console , In the network layer, we can see

Browser pre check found that the status code is 307, That must be redirection , And a point of attention ,Non-Authoriatative-Reason was HTTPS, We've already nginx Of https Instead of http, The domain name visited is also http, So there must be something wrong with this place
add_header Strict-Transport-Security "max-age=63072000" always;The reason is mine nginx There is this configuration in the configuration , It means Inform the browser that all requests for the current domain name use https, That's why I ask for http, stay options When detecting , Automatically redirect me to https, and cros It is stipulated that before the pre inspection is completed , Redirection is not allowed , So it leads to the problem here
Remove this sentence , Or change it to the following form , restart nginx, Clean up browser cache , Or use traceless mode to access ,options There will be no redirection .
add_header Strict-Transport-Security max-age=0;
边栏推荐
- [Linux] install redis
- 颜值爆表!推荐两款JSON可视化工具,配合Swagger使用真香
- Matlab draws the system response under different damping
- Voice data acquisition - real time voice data visualization
- Kgdb debug kernel cannot execute breakpoints and kdb-22:permisson denied
- Sound processing - Mel frequency cepstrum coefficient (MFCC)
- flask_restful中的输出域(Resource、fields、marshal、marshal_with)
- 已解决SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in position 2-3: truncated
- TDengine 助力西门子轻量级数字化解决方案 SIMICAS 简化数据处理流程
- es6 class 继承的重点
猜你喜欢

jvm--字节码浅析

Shardingsphere kernel principle

【Liunx】MariaDB/MySQL定时全量备份脚本及数据恢复

It is thought-provoking: is syntax really important? Qiu Xipeng group proposed a powerful baseline for aspect based emotional analysis

搭建 Samba 服务

游戏玩家问题

A few simple steps to realize the sharing network for industrial raspberry pie

MySQL master-slave architecture, read-write separation, and high availability architecture

MySQL 索引、事务与存储引擎

MySQL日志管理、备份与恢复
随机推荐
Eslint's error message module error (from./node_modules/ [email protected] @Eslint loader / index. JS)
ECCV 2022 | 同时完成四项跟踪任务!Unicorn: 迈向目标跟踪的大统一
Establishment of NFS server
Echats关系图les-miserables的图表详细解析(和弦图)
【英雄哥六月集训】第 26天: 并查集
Program translation and execution, from editing, preprocessing, compilation, assembly, linking to execution
kgdb调试内核无法执行断点及kdb-22:Permisson denied
PHP generates text and image watermarks
分享机器学习笔记(PDF版)+实战项目(数据集+代码)
Wind10 configure ADB command
[Linux] mariadb/mysql scheduled full backup script and data recovery
[brother hero July training] day 16: queue
Google browser screenshot tips
家庭琐事问题
Sound processing - Mel frequency cepstrum coefficient (MFCC)
数据库操作基础语句
Different binary conversion of MATLAB
Matlab discrete event system simulation experiment
flask_ Output fields in restful (resources, fields, marshal, marshal_with)
7z用法