feat(dashboard): complete React cutover
This commit is contained in:
1 parent
d5f0175dc2
commit
ec0cd1318b
13 files changed
+50
-4291
No files matched your search
+1
-1
@@ -55,7 +55,7 @@ export function createDashboardSessionRouter(token: string): Router {
|
||||
router.get('/auth/login', (_req, res) => {
|
||||
res
|
||||
.set('Cache-Control', 'no-cache, no-store, must-revalidate')
|
||||
.set('Content-Security-Policy', "default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; form-action 'self'")
|
||||
.set('Content-Security-Policy', "default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; connect-src 'self'; form-action 'self'")
|
||||
.type('html')
|
||||
.send(`<!doctype html><title>Dashboard sign in</title><form id="login"><label>Dashboard token <input name="token" type="password" required autofocus></label><button>Sign in</button></form><script>document.getElementById('login').addEventListener('submit',async(e)=>{e.preventDefault();const r=await fetch('/auth/session',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({token:new FormData(e.target).get('token')})});if(r.ok)location='/';else alert('Invalid dashboard token');});</script>`);
|
||||
});
|
||||
|
||||
@@ -4,7 +4,6 @@ import path from 'node:path';
|
||||
export interface DashboardAssets {
|
||||
directory: string;
|
||||
indexFile: string;
|
||||
isLegacy: boolean;
|
||||
}
|
||||
|
||||
export type FileExists = (filePath: string) => boolean;
|
||||
@@ -20,15 +19,10 @@ export function resolveDashboardAssets(
|
||||
return {
|
||||
directory: reactDirectory,
|
||||
indexFile: reactIndexFile,
|
||||
isLegacy: false,
|
||||
};
|
||||
}
|
||||
|
||||
const legacyDirectory = path.join(workspaceDirectory, 'public');
|
||||
|
||||
return {
|
||||
directory: legacyDirectory,
|
||||
indexFile: path.join(legacyDirectory, 'index.html'),
|
||||
isLegacy: true,
|
||||
};
|
||||
throw new Error(
|
||||
`React dashboard build is missing at ${reactIndexFile}. Run npm run dashboard:build before starting the web server.`,
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user