Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.