From d28b66c933120287523ff9b130b79cb39308a9c0 Mon Sep 17 00:00:00 2001 From: takecchi Date: Thu, 15 Feb 2024 16:09:58 +0900 Subject: [PATCH 1/2] =?UTF-8?q?.well-known/*=E5=AE=9B=E3=81=AE=E3=83=AA?= =?UTF-8?q?=E3=82=AF=E3=82=A8=E3=82=B9=E3=83=88=E3=82=92API=E3=81=AB?= =?UTF-8?q?=E8=BB=A2=E9=80=81=E3=81=99=E3=82=8B=E8=A8=AD=E5=AE=9A=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sst.config.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sst.config.ts b/sst.config.ts index b6689429..7696ed40 100644 --- a/sst.config.ts +++ b/sst.config.ts @@ -1,5 +1,13 @@ import { SSTConfig } from 'sst'; import { NextjsSite } from 'sst/constructs'; +import { HttpOrigin } from 'aws-cdk-lib/aws-cloudfront-origins'; +import { + AllowedMethods, + CachePolicy, + OriginProtocolPolicy, + OriginRequestPolicy, + ViewerProtocolPolicy, +} from 'aws-cdk-lib/aws-cloudfront'; export default { config(_input) { @@ -28,6 +36,21 @@ export default { warm: 100, memorySize: '2048 MB', logging: 'combined', + cdk: { + distribution: { + additionalBehaviors: { + '.well-known/*': { + origin: new HttpOrigin(`api.${domain}`, { + protocolPolicy: OriginProtocolPolicy.MATCH_VIEWER, + }), + viewerProtocolPolicy: ViewerProtocolPolicy.ALLOW_ALL, + allowedMethods: AllowedMethods.ALLOW_ALL, + cachePolicy: CachePolicy.CACHING_DISABLED, + originRequestPolicy: OriginRequestPolicy.ALL_VIEWER, + }, + }, + }, + }, }); stack.addOutputs({ From fea8b06bc619f9d8cef4812931ad7c3ab40f5edd Mon Sep 17 00:00:00 2001 From: takecchi Date: Thu, 15 Feb 2024 17:47:51 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E3=83=AD=E3=83=BC=E3=82=AB=E3=83=AB?= =?UTF-8?q?=E7=92=B0=E5=A2=83=E5=90=91=E3=81=91=E3=81=AE=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proxy.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/proxy.js b/proxy.js index d920cac7..a74cd3a3 100644 --- a/proxy.js +++ b/proxy.js @@ -9,6 +9,16 @@ const handle = app.getRequestHandler(); // Next.js を localhost:3000 で起動 app.prepare().then(() => { const server = express(); + + // .well-known/*へのリクエストをプロキシする + server.use( + '/.well-known/*', + createProxyMiddleware({ + target: 'http://localhost:8080', + changeOrigin: true, + }), + ); + server.all('*', (req, res) => { return handle(req, res); });