From befde35decd89350fca1a4191e1cb00f18ba6f8c Mon Sep 17 00:00:00 2001 From: Blayne Chard Date: Thu, 28 Jul 2022 15:50:55 +1200 Subject: [PATCH 1/4] fix(lambda-tiler): increase source cahe to approx 1GB --- packages/lambda-tiler/src/util/source.cache.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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); From 9fa2c894f74f3d58d65bb6f0796ff82c557564c7 Mon Sep 17 00:00:00 2001 From: Blayne Chard Date: Thu, 28 Jul 2022 16:19:20 +1200 Subject: [PATCH 2/4] fix(lambda-tiler): always include access-control-allow-origin --- packages/_infra/src/serve/lambda.tiler.ts | 6 ------ packages/lambda-tiler/src/index.ts | 4 +--- 2 files changed, 1 insertion(+), 9 deletions(-) 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..2ad6db122 100644 --- a/packages/lambda-tiler/src/index.ts +++ b/packages/lambda-tiler/src/index.ts @@ -41,9 +41,7 @@ handler.router.hook('response', (req, res) => { }); // FunctionURLs automatically inject CORS responses for us - if (!(req instanceof LambdaUrlRequest) && req.headers.has('origin')) { - res.header('access-control-allow-origin', '*'); - } + res.header('access-control-allow-origin', '*'); }); // CORS is handled by function url hook so just return ok if the route exists From 7f3061e636889bf074a02f1c80580b8625f476b1 Mon Sep 17 00:00:00 2001 From: Blayne Chard Date: Thu, 28 Jul 2022 16:22:53 +1200 Subject: [PATCH 3/4] refactor: fixup lint --- packages/lambda-tiler/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/lambda-tiler/src/index.ts b/packages/lambda-tiler/src/index.ts index 2ad6db122..89f5a5c6f 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'; @@ -44,7 +44,7 @@ handler.router.hook('response', (req, res) => { 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(); From 3b22a0982077bf8493e9caac6b5828e0f6cbef7e Mon Sep 17 00:00:00 2001 From: Blayne Chard Date: Thu, 28 Jul 2022 16:23:38 +1200 Subject: [PATCH 4/4] refactor: fixup comment --- packages/lambda-tiler/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/lambda-tiler/src/index.ts b/packages/lambda-tiler/src/index.ts index 89f5a5c6f..584dfad4e 100644 --- a/packages/lambda-tiler/src/index.ts +++ b/packages/lambda-tiler/src/index.ts @@ -40,7 +40,7 @@ handler.router.hook('response', (req, res) => { cacheB: CoSources.cache.cacheB.size, }); - // FunctionURLs automatically inject CORS responses for us + // Force access-control-allow-origin to everything res.header('access-control-allow-origin', '*'); });