mirror of
https://github.com/umami-software/umami.git
synced 2025-12-06 01:18:00 +01:00
feat: add CORS headers to any value of COLLECT_API_ENDPOINT in addition to /api/* endpoints
Signed-off-by: Louis Vallat <contact@louis-vallat.dev>
This commit is contained in:
parent
bf9a069aa0
commit
0d153a27dc
1 changed files with 25 additions and 6 deletions
|
|
@ -59,15 +59,29 @@ const trackerHeaders = [
|
|||
},
|
||||
];
|
||||
|
||||
const apiHeaders = [
|
||||
{
|
||||
key: 'Access-Control-Allow-Origin',
|
||||
value: '*'
|
||||
},
|
||||
{
|
||||
key: 'Access-Control-Allow-Headers',
|
||||
value: '*'
|
||||
},
|
||||
{
|
||||
key: 'Access-Control-Allow-Methods',
|
||||
value: 'GET, DELETE, POST, PUT'
|
||||
},
|
||||
{
|
||||
key: 'Access-Control-Max-Age',
|
||||
value: corsMaxAge || '86400'
|
||||
},
|
||||
];
|
||||
|
||||
const headers = [
|
||||
{
|
||||
source: '/api/:path*',
|
||||
headers: [
|
||||
{ key: 'Access-Control-Allow-Origin', value: '*' },
|
||||
{ key: 'Access-Control-Allow-Headers', value: '*' },
|
||||
{ key: 'Access-Control-Allow-Methods', value: 'GET, DELETE, POST, PUT' },
|
||||
{ key: 'Access-Control-Max-Age', value: corsMaxAge || '86400' },
|
||||
],
|
||||
headers: apiHeaders
|
||||
},
|
||||
{
|
||||
source: '/:path*',
|
||||
|
|
@ -89,6 +103,11 @@ if (trackerScriptURL) {
|
|||
}
|
||||
|
||||
if (collectApiEndpoint) {
|
||||
headers.push({
|
||||
source: collectApiEndpoint,
|
||||
headers: apiHeaders,
|
||||
});
|
||||
|
||||
rewrites.push({
|
||||
source: collectApiEndpoint,
|
||||
destination: '/api/send',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue