mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 07:30:04 +00:00
724c88c201
A mechanical prettier --write over server/src, server/tests, server/scripts and shared/src with the workspaces' .prettierrc; nothing but layout and import order changes, and every file keeps the same set of imports. shared is formatted throughout and its format baseline is empty. The server baseline keeps the 35 files that Prettier would grow past their lint:size limit (they need a split first, which is not a formatting change), and the generated entity files stay as their generator writes them.
20 lines
758 B
TypeScript
20 lines
758 B
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import type { NestMiddleware } from '@nestjs/common';
|
|
|
|
import type { Request, Response, NextFunction } from 'express';
|
|
|
|
/**
|
|
* Helmet's COOP: same-origin isolates the consent popup from its cross-origin
|
|
* opener (ChatGPT etc.), making window.opener null and breaking the OAuth flow —
|
|
* so /oauth/consent relaxes it. Runs after helmet (Nest middleware registers
|
|
* during init, helmet is pre-init) and simply overwrites the header, exactly
|
|
* like the pre-init override it replaces.
|
|
*/
|
|
@Injectable()
|
|
export class ConsentCoopMiddleware implements NestMiddleware {
|
|
use(_req: Request, res: Response, next: NextFunction): void {
|
|
res.setHeader('Cross-Origin-Opener-Policy', 'unsafe-none');
|
|
next();
|
|
}
|
|
}
|