diff --git a/.changeset/kind-walls-live.md b/.changeset/kind-walls-live.md new file mode 100644 index 0000000000..57f040e2c7 --- /dev/null +++ b/.changeset/kind-walls-live.md @@ -0,0 +1,5 @@ +--- +'@techdocs/cli': patch +--- + +Fix how the cli server mocks the new auth cookie endpoint. diff --git a/packages/techdocs-cli/src/lib/httpServer.ts b/packages/techdocs-cli/src/lib/httpServer.ts index 08987f3f1d..252004c7de 100644 --- a/packages/techdocs-cli/src/lib/httpServer.ts +++ b/packages/techdocs-cli/src/lib/httpServer.ts @@ -59,6 +59,18 @@ export default class HTTPServer { const proxyHandler = this.createProxy(); const server = http.createServer( (request: http.IncomingMessage, response: http.ServerResponse) => { + // This endpoind is used by the frontend to issue a cookie for the user. + // But the MkDocs server doesn't expose it as a the Backestage backend does. + // So we need to fake it here to prevent 404 errors. + if (request.url === '/api/techdocs/cookie') { + const oneHourInMilliseconds = 60 * 60 * 1000; + const expiresAt = new Date(Date.now() + oneHourInMilliseconds); + const cookie = { expiresAt: expiresAt.toISOString() }; + response.setHeader('Content-Type', 'application/json'); + response.end(JSON.stringify(cookie)); + return; + } + if (request.url?.startsWith(this.proxyEndpoint)) { const [proxy, forwardPath] = proxyHandler(request);