Skip to content

Commit

Permalink
Fix proxy path mapping for /api endpoint (#142)
Browse files Browse the repository at this point in the history
fixes #141

Signed-off-by: Sean Sundberg <[email protected]>
  • Loading branch information
seansund authored Oct 21, 2023
1 parent 91b9058 commit 0761478
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,17 @@ const createServer = () => {
app.get(LOGOUT2_URL, logout);

const apiProxy = proxy(BACKEND_HOST, {
proxyReqPathResolver: req => url.parse(req.baseUrl).path
proxyReqPathResolver: req => {
const origPath = url.parse(req.baseUrl).path

const path = origPath.replace(/^\/api/, '')
console.log(`Proxy path: ${origPath} -> ${path}`)

return path
}
});
app.use('/api/*', apiProxy);
app.use('/api', apiProxy);

const graphqlProxy = proxy(`${BACKEND_HOST}/graphql`, {
proxyReqPathResolver: req => url.parse(req.baseUrl).path
Expand Down

0 comments on commit 0761478

Please sign in to comment.