当前位置:网站首页>[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)
边栏推荐
- WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after conne
- JSON data flattening pd json_ normalize
- Yugu p1020 missile interception (binary search)
- 运放电路的反馈电阻上并联一个电容是什么作用
- Recursive method to construct binary tree from preorder and inorder traversal sequence
- Notes on PHP penetration test topics
- Cnopendata American Golden Globe Award winning data
- Avatary的LiveDriver试用体验
- 2022 welder (elementary) judgment questions and online simulation examination
- 2022 recurrent training question bank and answers of refrigeration and air conditioning equipment operation
猜你喜欢

json 数据展平pd.json_normalize

JS quick start (I)

Es FAQ summary

让Livelink初始Pose与动捕演员一致

Niu Mei's mathematical problem --- combinatorial number

2022 tea master (intermediate) examination questions and mock examination

Complex network modeling (I)

【数字IC验证快速入门】13、SystemVerilog interface 和 program 学习

Qt学习27 应用程序中的主窗口

快速使用 Jacoco 代码覆盖率统计
随机推荐
[quick start of Digital IC Verification] 17. Basic grammar of SystemVerilog learning 4 (randomization)
2022 National latest fire-fighting facility operator (primary fire-fighting facility operator) simulation questions and answers
Introduction à l'objet blob
Linux server development, MySQL index principle and optimization
LeetCode中等题之我的日程安排表 I
运放电路的反馈电阻上并联一个电容是什么作用
数据库实时同步利器——CDC(变化数据捕获技术)
[UVM foundation] what is transaction
Zsh shell adds automatic completion and syntax highlighting
追风赶月莫停留,平芜尽处是春山
Network learning (III) -- highly concurrent socket programming (epoll)
芯片 设计资料下载
Empire CMS collection Empire template program general
2022 recurrent training question bank and answers of refrigeration and air conditioning equipment operation
Example of file segmentation
力扣(LeetCode)187. 重复的DNA序列(2022.07.06)
Main window in QT learning 27 application
Real time monitoring of dog walking and rope pulling AI recognition helps smart city
Roulette chart 2 - writing of roulette chart code
Thinkcmf6.0安装教程