Skip to content

Instantly share code, notes, and snippets.

@gmcdev
Created May 17, 2022 02:31
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 gmcdev/f1e13b67f2926be2975bd56fa8fd1416 to your computer and use it in GitHub Desktop.
Save gmcdev/f1e13b67f2926be2975bd56fa8fd1416 to your computer and use it in GitHub Desktop.
// this route proxies static site requests to Review Page Builder
// Requests are secured by Sheet membership to this route.
// TODO: Maintain Google Drive API file permission cache
app.use(
'/dps/review/:ssid/:sid',
[authUser.redirectForAccess, authSsm.hasViewAccess],
(req, res, next) => {
// using the session ensures that the session cookie is included on every request
// otherwise, RPB will send its own session cookie on subsequent requests, which won't be authorized.
if (req.session.view) {
req.session.view++
} else {
req.session.view = 1
}
/*
log(`TODO: verify access per Sheet ID: ${req.params.ssid}`)
*/
next()
},
proxy({
target: `${config.getInternalRpbOrigin()}`,
// pathRewrite: { '^/[^/]+/dps/review': '/dps-rpb' },
pathRewrite: {
'^/dps/review/[^/]+/[^/]+/content': '/dps-content',
'^/dps/review/[^/]+/[^/]+': '/dps-sites'
},
changeOrigin: true
})
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment