Skip to content

Instantly share code, notes, and snippets.

@xgenvn
Created July 21, 2020 07:53
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 xgenvn/04be5976d1884da77b0b11e8f6335a0a to your computer and use it in GitHub Desktop.
Save xgenvn/04be5976d1884da77b0b11e8f6335a0a to your computer and use it in GitHub Desktop.
NUXT proxy
const httpProxy = require('http-proxy')
const proxy = httpProxy.createProxyServer()
const API_URL = process.env.API_URL || 'https://api.mydomain.com'
export default function(req, res, next) {
proxy.web(req, res, {
target: API_URL
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment