Skip to content

Instantly share code, notes, and snippets.

@jasonmccallister
Created April 17, 2019 10: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 jasonmccallister/4b6008ee22718f5104ff3c6850185de0 to your computer and use it in GitHub Desktop.
Save jasonmccallister/4b6008ee22718f5104ff3c6850185de0 to your computer and use it in GitHub Desktop.
NuxtJS Server Middleware Proxy Passthrough
// lives at /api/index.js
const httpProxy = require('http-proxy')
const proxy = httpProxy.createProxyServer()
const API = process.env.API_URL || 'http://localhost:8080/v1alpha1/graphql'
export default function(req, res, next) {
proxy.web(req, res, {
target: API
})
}
// remainder of code left out
serverMiddleware: [
{
path: 'api',
handler: '~/api/index.js'
}
],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment