当我在本地服务器上进行API调用时,效果很好,但是在Heroku部署的应用程序上却不断收到404错误。
config.js文件
module.exports = {
devServer: {
proxy: {
'/api': {
target: 'https://simple-order-api.herokuapp.com',
},
},
},
};
store / index.js文件
Vue.use(Vuex);
export default new Vuex.Store({
strict: true,
state: {
baseUrl: '/api',
},
});
auth.js文件
actions: {
register({ commit, state }) {
commit('setRegisterError', null);
return HTTP().post('/auth/register', {
email: state.registerEmail,
password: state.registerPassword,
})
.then(({ data }) => {
commit('setToken', data.token);
router.push('/');
})
.catch(() => {
commit('setRegisterError', 'An error occured while creating your account');
});
},
};