mirror of
https://github.com/sasjs/server.git
synced 2026-01-10 07:50:05 +00:00
fix: setting CSRF Token for only rendering SPA
This commit is contained in:
@@ -6,11 +6,6 @@ const router = express.Router()
|
|||||||
|
|
||||||
router.use(csrfProtection)
|
router.use(csrfProtection)
|
||||||
|
|
||||||
router.use(function (req, res, next) {
|
|
||||||
res.cookie('XSRF-TOKEN', req.csrfToken())
|
|
||||||
next()
|
|
||||||
})
|
|
||||||
|
|
||||||
router.use('/', webRouter)
|
router.use('/', webRouter)
|
||||||
|
|
||||||
export default router
|
export default router
|
||||||
|
|||||||
@@ -6,10 +6,13 @@ import { getWebBuildFolderPath, loginWebValidation } from '../../utils'
|
|||||||
|
|
||||||
const webRouter = express.Router()
|
const webRouter = express.Router()
|
||||||
|
|
||||||
webRouter.get('/', async (_, res) => {
|
webRouter.get('/', async (req, res) => {
|
||||||
const indexHtmlPath = path.join(getWebBuildFolderPath(), 'index.html')
|
const indexHtmlPath = path.join(getWebBuildFolderPath(), 'index.html')
|
||||||
|
|
||||||
if (await fileExists(indexHtmlPath)) return res.sendFile(indexHtmlPath)
|
if (await fileExists(indexHtmlPath)) {
|
||||||
|
res.cookie('XSRF-TOKEN', req.csrfToken())
|
||||||
|
return res.sendFile(indexHtmlPath)
|
||||||
|
}
|
||||||
|
|
||||||
return res.send('Web Build is not present')
|
return res.send('Web Build is not present')
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user