Created
April 17, 2019 10:52
-
-
Save jasonmccallister/4b6008ee22718f5104ff3c6850185de0 to your computer and use it in GitHub Desktop.
NuxtJS Server Middleware Proxy Passthrough
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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