mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-14 11:53:49 +00:00
fix: resolve path to public assets in cloud
This commit is contained in:
committed by
Carlos Valente
parent
cc48ac8fd3
commit
23298bbe85
@@ -21,6 +21,20 @@ const publicAssets = new Set([
|
||||
'/site.webmanifest',
|
||||
]);
|
||||
|
||||
export function isPublicAssetRequest(originalUrl: string, prefix: string): boolean {
|
||||
const pathname = originalUrl.split('?')[0];
|
||||
|
||||
if (publicAssets.has(pathname)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (prefix && pathname.startsWith(prefix)) {
|
||||
return publicAssets.has(pathname.slice(prefix.length) || '/');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a login router with the provided prefix
|
||||
* @param {string} prefix - Prefix is used for the client hashes in Ontime Cloud
|
||||
@@ -81,7 +95,7 @@ export function makeAuthenticateMiddleware(prefix: string) {
|
||||
|
||||
function authenticateAndRedirect(req: Request, res: Response, next: NextFunction) {
|
||||
// Allow access to specific public assets without authentication
|
||||
if (publicAssets.has(req.originalUrl)) {
|
||||
if (isPublicAssetRequest(req.originalUrl, prefix)) {
|
||||
return next();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user