From b9ed3b2427593a279f129f6ee10064e5955fb5b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=93=E3=81=8B=E3=82=8A?= <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sat, 6 Jul 2024 11:46:43 +0900 Subject: [PATCH] =?UTF-8?q?fix(dev):=20dev=E3=82=B5=E3=83=BC=E3=83=90?= =?UTF-8?q?=E3=83=BC=E3=81=A7`/notes/`=E3=81=AB=E7=9B=B4=E3=81=A7=E3=82=A2?= =?UTF-8?q?=E3=82=AF=E3=82=BB=E3=82=B9=E3=81=97=E3=81=9F=E3=82=89=E3=82=B5?= =?UTF-8?q?=E3=83=BC=E3=83=90=E3=83=BC=E5=81=B4=E3=81=AE=E3=83=AC=E3=82=B9?= =?UTF-8?q?=E3=83=9D=E3=83=B3=E3=82=B9=E3=81=8C=E8=BF=94=E3=81=A3=E3=81=A6?= =?UTF-8?q?=E3=81=8F=E3=82=8B=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=20(#14137)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/vite.config.local-dev.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/frontend/vite.config.local-dev.ts b/packages/frontend/vite.config.local-dev.ts index f9dff13b15..0a88e489c1 100644 --- a/packages/frontend/vite.config.local-dev.ts +++ b/packages/frontend/vite.config.local-dev.ts @@ -1,6 +1,8 @@ import dns from 'dns'; import { readFile } from 'node:fs/promises'; +import type { IncomingMessage } from 'node:http'; import { defineConfig } from 'vite'; +import type { UserConfig } from 'vite'; import * as yaml from 'js-yaml'; import locales from '../../locales/index.js'; import { getConfig } from './vite.config.js'; @@ -14,7 +16,15 @@ const { port } = yaml.load(await readFile('../../.config/default.yml', 'utf-8')) const httpUrl = `http://localhost:${port}/`; const websocketUrl = `ws://localhost:${port}/`; -const devConfig = { +// activitypubリクエストはProxyを通し、それ以外はViteの開発サーバーを返す +function varyHandler(req: IncomingMessage) { + if (req.headers.accept?.includes('application/activity+json')) { + return null; + } + return '/index.html'; +} + +const devConfig: UserConfig = { // 基本の設定は vite.config.js から引き継ぐ ...defaultConfig, root: 'src', @@ -54,15 +64,11 @@ const devConfig = { '/inbox': httpUrl, '/notes': { target: httpUrl, - headers: { - 'Accept': 'application/activity+json', - }, + bypass: varyHandler, }, '/users': { target: httpUrl, - headers: { - 'Accept': 'application/activity+json', - }, + bypass: varyHandler, }, '/.well-known': { target: httpUrl,