fix: mock cookie endpoint

Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
Camila Belo
2024-03-25 09:54:53 +01:00
parent 177a41a2ee
commit 1299dd8c1a
@@ -59,6 +59,15 @@ 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.
// It is necessary because the MkDocs server doesn't expose it.
if (request.url === '/api/techdocs/.backstage/v1-cookie') {
const expiresAt = new Date(Date.now() + 60 * 60 * 1000);
const cookie = { expiresAt: expiresAt.toISOString() };
response.end(JSON.stringify(cookie));
return;
}
if (request.url?.startsWith(this.proxyEndpoint)) {
const [proxy, forwardPath] = proxyHandler(request);