Merge pull request #3282 from LouisVallat/dev
add CORS headers to any value of COLLECT_API_ENDPOINT in addition to /api/* endpoints
This commit is contained in:
@@ -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 = [
|
const headers = [
|
||||||
{
|
{
|
||||||
source: '/api/:path*',
|
source: '/api/:path*',
|
||||||
headers: [
|
headers: 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' },
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
source: '/:path*',
|
source: '/:path*',
|
||||||
@@ -89,6 +103,11 @@ if (trackerScriptURL) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (collectApiEndpoint) {
|
if (collectApiEndpoint) {
|
||||||
|
headers.push({
|
||||||
|
source: collectApiEndpoint,
|
||||||
|
headers: apiHeaders,
|
||||||
|
});
|
||||||
|
|
||||||
rewrites.push({
|
rewrites.push({
|
||||||
source: collectApiEndpoint,
|
source: collectApiEndpoint,
|
||||||
destination: '/api/send',
|
destination: '/api/send',
|
||||||
|
|||||||
Reference in New Issue
Block a user