Skip to content

Commit 71bd4ae

Browse files
committed
Added proxy
1 parent 711cf64 commit 71bd4ae

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

nuxt.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,17 @@ module.exports = {
6666
** Axios configuration
6767
*/
6868
axios: {
69-
baseURL: process.env.API_URL
69+
proxy: true
70+
},
71+
72+
/*
73+
** Proxy configuration
74+
*/
75+
proxy: {
76+
'/api/': {
77+
target: process.env.API_URL,
78+
pathRewrite: { '^/api/': '' }
79+
}
7080
},
7181

7282
/*

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"dependencies": {
2222
"@nuxtjs/axios": "^5.9.5",
2323
"@nuxtjs/google-gtag": "^1.0.4",
24+
"@nuxtjs/proxy": "^1.3.3",
2425
"@nuxtjs/pwa": "^3.0.0-beta.20",
2526
"animated-number-vue": "^1.0.0",
2627
"apexcharts": "^3.17.0",

store/actions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ export default {
22
async nuxtServerInit({ commit }, ctx) {
33
await Promise
44
.all([
5-
this.$axios.get(process.env.NODE_ENV !== 'production' ? 'latest.json' : '/latest'),
6-
this.$axios.get(process.env.NODE_ENV !== 'production' ? 'locations.json' : '/locations')
5+
this.$axios.get(process.env.NODE_ENV !== 'production' ? 'latest.json' : '/api/latest'),
6+
this.$axios.get(process.env.NODE_ENV !== 'production' ? 'locations.json' : '/api/locations')
77
])
88
.then(res => {
99
commit('SET_LATEST', res[0].data.latest)
@@ -17,7 +17,7 @@ export default {
1717
async getOverviewByCountry({ commit }, id) {
1818
await this.$axios
1919
.get(
20-
process.env.NODE_ENV !== 'production' ? 'location-16.json' : `/locations/${id}`
20+
process.env.NODE_ENV !== 'production' ? 'location-16.json' : `/api/locations/${id}`
2121
)
2222
.then(res => {
2323
if (res.status === 200) {

0 commit comments

Comments
 (0)