15、Nuxt.js代理转发解决跨域问题

编程入门 行业动态 更新时间:2024-10-27 14:19:17

15、<a href=https://www.elefans.com/category/jswz/34/1771106.html style=Nuxt.js代理转发解决跨域问题"/>

15、Nuxt.js代理转发解决跨域问题

nuxt.config.js

export default {...// Modules: /config-modulesmodules: ["@nuxtjs/axios"],axios: {proxy: true, // 开启代理转发prefix: "/api"},// 代理转发proxy: {'/api': {target: "",pathRewrite: { "^/api": "",changeOrigin: true }}},...
}

pages\index.vue

/*** 加载组件之前服务端调用*/async asyncData({ $axios }) {try {let res = await $axios.$get("/test");console.log(res.data)return {res: res?.data};} catch (err) {console.log(err);}},

更多推荐

15、Nuxt.js代理转发解决跨域问题

本文发布于:2023-11-16 11:11:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619685.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Nuxt   js

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!