summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/web/ClientServerService.ts
diff options
context:
space:
mode:
author饺子w (Yumechi) <35571479+eternal-flame-AD@users.noreply.github.com>2025-09-04 23:55:37 -0500
committerGitHub <noreply@github.com>2025-09-05 13:55:37 +0900
commita92fd8856a77e8a80e8e9294a091e08f12f86c3f (patch)
tree840d708491e249f156b4ef65202c9a4433e0c17c /packages/backend/src/server/web/ClientServerService.ts
parentfix(frontend): エラー画像が横に引き伸ばされてしまう問題... (diff)
downloadmisskey-a92fd8856a77e8a80e8e9294a091e08f12f86c3f.tar.gz
misskey-a92fd8856a77e8a80e8e9294a091e08f12f86c3f.tar.bz2
misskey-a92fd8856a77e8a80e8e9294a091e08f12f86c3f.zip
feat(backend): Send Clear-Site-Data header on /flush (#16517)
* feat(backend): Send Clear-Site-Data header on /flush Signed-off-by: eternal-flame-AD <yume@yumechi.jp> * simplify check on flush.pug Signed-off-by: eternal-flame-AD <yume@yumechi.jp> --------- Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
Diffstat (limited to 'packages/backend/src/server/web/ClientServerService.ts')
-rw-r--r--packages/backend/src/server/web/ClientServerService.ts19
1 files changed, 18 insertions, 1 deletions
diff --git a/packages/backend/src/server/web/ClientServerService.ts b/packages/backend/src/server/web/ClientServerService.ts
index b515a0c0c8..3cd83efa1a 100644
--- a/packages/backend/src/server/web/ClientServerService.ts
+++ b/packages/backend/src/server/web/ClientServerService.ts
@@ -201,6 +201,8 @@ export class ClientServerService {
@bindThis
public createServer(fastify: FastifyInstance, options: FastifyPluginOptions, done: (err?: Error) => void) {
+ const configUrl = new URL(this.config.url);
+
fastify.register(fastifyView, {
root: _dirname + '/views',
engine: {
@@ -239,7 +241,6 @@ export class ClientServerService {
done();
});
} else {
- const configUrl = new URL(this.config.url);
const urlOriginWithoutPort = configUrl.origin.replace(/:\d+$/, '');
const port = (process.env.VITE_PORT ?? '5173');
@@ -887,6 +888,22 @@ export class ClientServerService {
[, ...target.split('/').filter(x => x), ...source.split('/').filter(x => x).splice(depth)].join('/');
fastify.get('/flush', async (request, reply) => {
+ let sendHeader = true;
+
+ if (request.headers['origin']) {
+ const originURL = new URL(request.headers['origin']);
+ if (originURL.protocol !== 'https:') { // Clear-Site-Data only supports https
+ sendHeader = false;
+ }
+ if (originURL.host !== configUrl.host) {
+ sendHeader = false;
+ }
+ }
+
+ if (sendHeader) {
+ reply.header('Clear-Site-Data', '"*"');
+ }
+ reply.header('Set-Cookie', 'http-flush-failed=1; Path=/flush; Max-Age=60');
return await reply.view('flush');
});