跨域处理

This commit is contained in:
luJianJun 2023-07-12 11:10:01 +08:00
parent 8450f0add1
commit 8f131614f2
4 changed files with 29 additions and 1 deletions

View File

@ -0,0 +1,7 @@
import axios from "./axios";
export default{
index:(params={})=>{
return axios.get('/tenement/pc/api/home',params)
}
}

View File

@ -5,7 +5,8 @@ import router from '../router/index'
// let protocol = window.location.protocol; //协议
// let host = window.location.host; //主机
// axios.defaults.baseURL = protocol + "//" + host;
axios.defaults.baseURL = 'https://app.gter.net'
// axios.defaults.baseURL = 'https://app.gter.net'
axios.defaults.baseURL = '/index'
// axios.defaults.emulateJSON = true
// axios.defaults.withCredentials = true

View File

@ -166,12 +166,14 @@
</template>
<script setup>
import { reactive } from "vue";
import listItem from "../components/apartmentList/apartmentList.vue";
import pageTopBar from '../components/pageTopBar/pageTopBar.vue';
import indexWaterfallBox from "../components/indexWaterfallBox/indexWaterfallBox.vue";
import seachModule from "../components/seachModule/seachModule.vue";
import indexRegularBox from '../components/indexRegularBox/indexRegularBox.vue';
import headerNavigation from '../components/public/head.vue'
import api from "../utils/api";
//
let informationData = [
@ -194,6 +196,12 @@ let ListSelectBtn = [
text: '已认证'
},
]
let indexData= reactive({data:[]})
api.index().then(res=>{
console.log(res)
})
</script>
<script>
export default {

View File

@ -35,6 +35,18 @@ module.exports = defineConfig({
.use('sass-loader')
.loader('sass-loader')
.end()
},
devServer: {
proxy: {
'/index': {
target: 'https://app.gter.net',//请求的接口的前缀
changeOrigin:true,
rewrite: (path) => path.replace(/^\/index/, ''),
pathRewrite:{
'^/index':''
}
}
}
}