techdocs-cli: unified dev and production build through config detection

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-02-05 11:18:43 +01:00
parent bbd59ed355
commit b70c186194
8 changed files with 94 additions and 38 deletions
+10 -2
View File
@@ -71,10 +71,18 @@ export default class HTTPServer {
response.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
request.url = forwardPath;
return proxy.web(request, response);
proxy.web(request, response);
return;
}
return serveHandler(request, response, {
// This endpoint is used by the frontend to detect where the backend is running.
if (request.url === '/.detect') {
response.setHeader('Content-Type', 'text/plain');
response.end('techdocs-cli-server');
return;
}
serveHandler(request, response, {
public: this.backstageBundleDir,
trailingSlash: true,
rewrites: [{ source: '**', destination: 'index.html' }],