Skip to content

Commit

Permalink
fix: dev local spa request error
Browse files Browse the repository at this point in the history
  • Loading branch information
caoli committed Sep 5, 2018
1 parent 8d05f71 commit a79a408
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"globals": {
"EASY_ENV_IS_PROD": true,
"EASY_ENV_IS_NODE": true,
"EASY_ENV_IS_BROWSER": true
"EASY_ENV_IS_BROWSER": true,
"EASY_ENV_IS_DEV": true
},
"parser": "babel-eslint"
}
5 changes: 3 additions & 2 deletions app/web/page/app/store/app/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import axios from 'axios';

Vue.use(Vuex);

const host = EASY_ENV_IS_DEV ? 'http://127.0.0.1:7001' : '';
const actions = {

FETCH_ARTICLE_LIST: ({ commit, dispatch, state }) => {
if (!state.articleList.length) {
return axios.get('/app/api/article/list')
return axios.get(`${host}/app/api/article/list`)
.then(response => {
const data = response.data.list;
commit(Type.SET_ARTICLE_LIST, data);
Expand All @@ -23,7 +24,7 @@ const actions = {

FETCH_ARTICLE_DETAIL: ({ commit, dispatch, state }, { id }) => {
if (state.article.id !== id) {
return axios.get(`/app/api/article/${id}`)
return axios.get(`${host}/app/api/article/${id}`)
.then(response => {
const data = response.data;
commit(Type.SET_ARTICLE_DETAIL, data);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "egg-vue-webpack-boilerplate",
"version": "4.1.1",
"version": "4.2.0",
"description": "基于 easywebpack-vue 和 egg-view-vue-ssr 插件的 egg + vue 服务端渲染同构工程骨架项目",
"scripts": {
"dev": "egg-bin dev",
Expand Down Expand Up @@ -41,7 +41,7 @@
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-env": "^1.6.0",
"easywebpack-cli": "^3.8.0",
"easywebpack-cli": "^3.11.2",
"easywebpack-vue": "^4.0.0",
"egg-bin": "^4.3.7",
"egg-logview": "^1.0.0",
Expand Down

0 comments on commit a79a408

Please sign in to comment.