当前位置:网站首页>Solution of cross domain problems
Solution of cross domain problems
2022-07-23 06:05:00 【Diesel】
Cross-domain problem
Understand cross domain issues
On safety grounds , The browser requires that your website cannot be executed / Visit resources on other websites
Cross domain impact
- Browser local storage cannot be used
- DOM object ,JS Object cannot get
- AJAX Can't use
Cross domain problem solving
- utilize HTML The characteristics of the label script,a,iframe,img,link etc.
- Use agents on the front end to solve
- Solve in the server section
CORS - Cross-domain resource sharing , Solve this problem by adding response header information
stay Vue.js To solve
1. porxy agent
newly build vue.config.js
// Node.js The modules inside
module.exports = {
// http://localhost:8080/api/test
// =>
// http://localhost:8000/test
devServer: {
proxy: {
'/api': {
// target: 'http://localhost:8000',
target: 'http://django.t.mukewang.com',
changeOrigin: true,
pathRewrite: {
// '^/api': '' // need rewrite Rewrite the URL
},
'/test': {
// target: 'http://localhost:8000',
target: 'http://localhost:9527',
changeOrigin: true,
pathRewrite: {
'^/test': '' // need rewrite Rewrite the URL
}
}
}
}
}
}
2. adopt axios To achieve send access :
stay main.js Import installed axios, And mount it on the prototype
import { ajax } from '@/utils/ajax'
export default {
name: 'Home',
components: {
},
created () {
// ajax.get('http://django.t.mukewang.com/api/system/slider/list/?types=11')
ajax.get('http://localhost:8080/api/system/slider/list/?types=11').then(resp => {
console.log(' The result returned :', resp)
}).catch(err => {
console.log(' Request error :', err)
})
}
}
stay Django Solve cross domain problems in
边栏推荐
猜你喜欢
随机推荐
【基础3】——结构与函数
從鍵盤輸入一串字符,輸出不同的字符以及每個字符出現的次數。(輸出不按照順序)運用String類的常用方法解題
Shell programming specifications and variables
源码编译!!
详解虚拟机下三种联网模式
【基础6】——类、对象、类的封装、继承
构建知识库时,如何避免最常见的几个错误?
APUE进程深层理解fork和execl-程序代码里获取虚拟机IP地址
Implementing IO multiplexing in UNIX using epoll function to realize network socket server
基于知识图谱的职位推荐系统的设计与实现
Recent ACM insights and future ideas
File directory permissions
vim编辑器的使用
LC:剑指 Offer 05. 替换空格
Theoretical basis of machine learning
[第五空间2019 决赛]PWN5 ——两种解法
资产测绘流程
zstuAcm夏令营旗手
两个及其简单的TCPUDP程序,树莓派与pc间的通信
[jmeter] solution to Chinese garbled response content



![[jmeter] solution to Chinese garbled response content](/img/ff/3d68a0cc34486e0b6cb35291ce10c0.png)





