diff --git a/packages/_infra/src/serve/lambda.tiler.ts b/packages/_infra/src/serve/lambda.tiler.ts index 9864ba037..bc4416617 100644 --- a/packages/_infra/src/serve/lambda.tiler.ts +++ b/packages/_infra/src/serve/lambda.tiler.ts @@ -73,12 +73,6 @@ export class LambdaTiler extends Construct { this.functionUrl = new lambda.FunctionUrl(this, 'LambdaCogUrl', { function: this.lambdaNoVpc, authType: lambda.FunctionUrlAuthType.NONE, - cors: { - allowedOrigins: ['*'], - allowedMethods: [lambda.HttpMethod.GET], - allowCredentials: false, - maxAge: cdk.Duration.minutes(1), - }, }); if (props.staticBucketName) { diff --git a/packages/lambda-tiler/src/index.ts b/packages/lambda-tiler/src/index.ts index 145ee3670..584dfad4e 100644 --- a/packages/lambda-tiler/src/index.ts +++ b/packages/lambda-tiler/src/index.ts @@ -1,5 +1,5 @@ import { LogConfig } from '@basemaps/shared'; -import { LambdaHttpResponse, LambdaUrlRequest, lf } from '@linzjs/lambda'; +import { LambdaHttpResponse, lf } from '@linzjs/lambda'; import { tileAttributionGet } from './routes/attribution.js'; import { fontGet, fontList } from './routes/fonts.js'; import { healthGet } from './routes/health.js'; @@ -40,13 +40,11 @@ handler.router.hook('response', (req, res) => { cacheB: CoSources.cache.cacheB.size, }); - // FunctionURLs automatically inject CORS responses for us - if (!(req instanceof LambdaUrlRequest) && req.headers.has('origin')) { - res.header('access-control-allow-origin', '*'); - } + // Force access-control-allow-origin to everything + res.header('access-control-allow-origin', '*'); }); -// CORS is handled by function url hook so just return ok if the route exists +// CORS is handled by response hook so just return ok if the route exists handler.router.options('*', (req) => { const route = handler.router.router.find('GET', req.path); if (route == null) return NotFound(); diff --git a/packages/lambda-tiler/src/util/source.cache.ts b/packages/lambda-tiler/src/util/source.cache.ts index 02cc6a242..0b1d3bd6b 100644 --- a/packages/lambda-tiler/src/util/source.cache.ts +++ b/packages/lambda-tiler/src/util/source.cache.ts @@ -68,4 +68,5 @@ export class SourceCache { } } -export const CoSources = new SourceCache(256 * 1024 * 1024); +/** Approx 1GB */ +export const CoSources = new SourceCache(1000 * 1000 * 1000);