Merge branch 'dev' into jajaja

# Conflicts:
#	package.json
#	yarn.lock
This commit is contained in:
Mike Cao 2025-03-31 23:31:09 -05:00
commit c71e9b5707
11 changed files with 126 additions and 30 deletions

View file

@ -4,6 +4,18 @@ export const config = {
matcher: '/:path*',
};
const apiHeaders = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': '*',
'Access-Control-Allow-Methods': 'GET, DELETE, POST, PUT',
'Access-Control-Max-Age': process.env.CORS_MAX_AGE || '86400',
};
const trackerHeaders = {
'Access-Control-Allow-Origin': '*',
'Cache-Control': 'public, max-age=86400, must-revalidate',
};
function customCollectEndpoint(req) {
const collectEndpoint = process.env.COLLECT_API_ENDPOINT;
@ -13,7 +25,7 @@ function customCollectEndpoint(req) {
if (pathname.endsWith(collectEndpoint)) {
url.pathname = '/api/send';
return NextResponse.rewrite(url);
return NextResponse.rewrite(url, { headers: apiHeaders });
}
}
}
@ -28,7 +40,7 @@ function customScriptName(req) {
if (names.find(name => pathname.endsWith(name))) {
url.pathname = '/script.js';
return NextResponse.rewrite(url);
return NextResponse.rewrite(url, { headers: trackerHeaders });
}
}
}