vue 代理重定向_Vue代理设置不起作用

在Vue CLI 3.x项目中,发现根据某文章设置的package.json中的代理未生效,导致服务器无法接收到API请求。解决方法是创建vue.config.js文件,并在其中配置devServer的proxy选项,如下所示:`module.exports = { devServer: { proxy: { '/api': { target: 'http://localhost:9000', ws: true, changeOrigin: true } } } }` 这将确保API请求正确地被代理到本地9000端口。" 125153194,14366855,理解银行家算法:避免死锁的有效策略,"['算法', '死锁', '资源管理']
摘要由CSDN通过智能技术生成

I have a Vue project from @vue/cli 3.x.

The proxy I defined in package.json based on this article is not working. The destination server doesn't see the API request.

What am I missing here?

The vue file:

import { Component, Prop, Vue } from 'vue-property-decorator';

import VueResource from 'vue-resource';

Vue.use(VueResource);

@Component

export default class HelloWorld extends Vue {

@Prop() private msg!: string;

constructor() {

super();

this.$http.post('/api');

}

}

package.json:

"proxy": {

"/api": "http://localhost:9000/api"

},

解决方案

The article likely refers to an outdated method of setting up the proxy. The latest version of @vue/cli (cur

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值