Skip to content

Instantly share code, notes, and snippets.

@eeriksp
Last active May 5, 2018 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eeriksp/3e77c374be4b02a9b3d87dbe28f827dd to your computer and use it in GitHub Desktop.
Save eeriksp/3e77c374be4b02a9b3d87dbe28f827dd to your computer and use it in GitHub Desktop.
Vue proxyTable configuration to allow access to Django backend development server in development mode
proxyTable: {
'/api': {
target: 'http://127.0.0.1:8000',
changeOrigin: true
},
'/haldus': {
target: 'http://127.0.0.1:8000',
changeOrigin: true
},
'/static': {
target: 'http://127.0.0.1:8000',
changeOrigin: true
}
},
/*
Guidelines
1. Open config/index.js.
2. Find
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {},
3. Replace 'proxyTable: {}' with the given content
4. Find the axios configuration (for example api/index.js) and replace
Axios.create({baseURL: 'http://127.0.0.1:8000/api', timeout: 5000}),
with
Axios.create({baseURL: '/api', timeout: 5000}),
(The point is to eradicate the http://127.0.0.1:8000 part since it is already declared in the proxyTable.)
5. Restart the server (nmp run dev)
6. Now you can access the declared backend URLs (/api, /haldus, static) via the frontend server
(but of course you still need to keep the backend server running as the frontend server will still use it to fetch the data).
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment