当前位置:网站首页>[step on the pit series] H5 cross domain problem of uniapp
[step on the pit series] H5 cross domain problem of uniapp
2022-07-07 08:08:00 【The sea of waves】
List of articles
【 Step on the pit series 】uniapp And h5 Cross domain issues
Preface
Debug the mobile interface on the browser , appear Multiple... Are not allowed ‘Access-Control-Allow-Origin’ CORS Header information . And see Response Information returned , It is thought that there are many configurations on the server Settings for cross domain access , The problem caused by , So I've been looking for problems on the back end , After spending some time checking , Multiple cross domain access settings are not configured , And the real machine of the mobile terminal can be accessed normally , This has reversed the idea of investigation , Solve the problem from the front end .

What is cross-domain
Cross domain is a browser specific concept , finger js The code accesses sites other than its own source site . such as A In the web page of the site js Code , Request the B Site data , It's cross domain .
A and B To be considered a homogeneous domain , Then there must be the same agreement ( such as http and https No way. )、 Same domain name 、 And the same port number (port).
If you are doing App、 Small program, etc H5 platform , It does not involve cross domain issues .

How to solve
Solution :uni-app The official recommendation Use HBuilderX Browser built in Go preview , There will be no cross domain issues in built-in browsers ; But if it is Chrome This cross domain problem will appear when previewing in browser , Official recommendation install Allow-Control-Allow-Origin: * plug-in unit The way to solve . Reference resources :uni-app H5 Cross domain problem solution (CORS、Cross-Origin).
# Whether cross domain access is allowed CORS, If allowed , Set allowed domain names
accessControlAllowOrigin: '*'
# When cross domain access is allowed CORS, Methods and request headers that can be retrieved and returned
accessControlAllowMethods: GET, POST, OPTIONS
accessControlAllowHeaders: content-type, x-requested-with, x-ajax, x-token, x-remember
accessControlExposeHeaders: x-remember
Reference article
uni-app H5 Cross domain problem solution (CORS、Cross-Origin)
边栏推荐
- Chip information website Yite Chuangxin
- 探索干货篇!Apifox 建设思路
- Most elements
- WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after conne
- 数据库实时同步利器——CDC(变化数据捕获技术)
- 【无标题】
- QT learning 28 toolbar in the main window
- Real time monitoring of dog walking and rope pulling AI recognition helps smart city
- paddlepaddle 29 无模型定义代码下动态修改网络结构(relu变prelu,conv2d变conv3d,2d语义分割模型改为3d语义分割模型)
- 贝叶斯定律
猜你喜欢

数据库实时同步利器——CDC(变化数据捕获技术)

Quickly use Jacobo code coverage statistics

2022 National latest fire-fighting facility operator (primary fire-fighting facility operator) simulation questions and answers

复杂网络建模(一)

电池、电机技术受到很大关注,反而电控技术却很少被提及?

Li Kou interview question 04.01 Path between nodes

【数字IC验证快速入门】11、Verilog TestBench(VTB)入门

Complex network modeling (I)
![[Matlab] Simulink 自定义函数中的矩阵乘法工作不正常时可以使用模块库中的矩阵乘法模块代替](/img/e3/cceede6babae3c8a24336c81d98aa7.jpg)
[Matlab] Simulink 自定义函数中的矩阵乘法工作不正常时可以使用模块库中的矩阵乘法模块代替

调用 pytorch API完成线性回归
随机推荐
[UVM basics] summary of important knowledge points of "UVM practice" (continuous update...)
调用 pytorch API完成线性回归
json 数据展平pd.json_normalize
C language communication travel card background system
Introduction à l'objet blob
[quick start of Digital IC Verification] 17. Basic grammar of SystemVerilog learning 4 (randomization)
芯片资料 网站 易特创芯
贝叶斯定律
积分商城管理系统中应包含的四大项
C语言二叉树与建堆
有 Docker 谁还在自己本地安装 Mysql ?
Real time monitoring of dog walking and rope pulling AI recognition helps smart city
复杂网络建模(一)
快速使用 Jacoco 代码覆盖率统计
【数字IC验证快速入门】13、SystemVerilog interface 和 program 学习
LeetCode简单题之判断一个数的数字计数是否等于数位的值
Open source ecosystem | create a vibrant open source community and jointly build a new open source ecosystem!
JS quick start (I)
Leetcode 40: combined sum II
offer收割机:两个长字符串数字相加求和(经典面试算法题)