Created
May 17, 2022 02:31
-
-
Save gmcdev/f1e13b67f2926be2975bd56fa8fd1416 to your computer and use it in GitHub Desktop.
This file contains 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
// 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