mirror of
https://github.com/unraid/api.git
synced 2026-05-19 23:48:42 -05:00
feat: bypass cors middleware on get requests
This commit is contained in:
@@ -22,7 +22,7 @@ const saveApiReport = async (pathToReport: string) => {
|
||||
};
|
||||
|
||||
export const getLogs = async (req: Request, res: Response) => {
|
||||
const apiKey = req.headers['x-api-key'];
|
||||
const apiKey = req.headers['x-api-key'] || req.query.apiKey;
|
||||
const logPath = getters.paths()['log-base'];
|
||||
try {
|
||||
await saveApiReport(join(logPath, 'report.json'));
|
||||
|
||||
@@ -24,6 +24,10 @@ export const originMiddleware = (
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
): void => {
|
||||
if (req.method === 'GET' && req.query.apiKey && !req.headers.origin) {
|
||||
// Bypass GET request headers on requests to the log endpoint
|
||||
return next();
|
||||
}
|
||||
// Dev Mode Bypass
|
||||
const origin = req.get('Origin')?.toLowerCase() ?? '';
|
||||
const allowedOrigins = getAllowedOrigins();
|
||||
|
||||
Reference in New Issue
Block a user