This commit is contained in:
Philipinho
2024-12-11 22:13:42 +00:00
parent 1302b1b602
commit 5506fe5e73
4 changed files with 36 additions and 2 deletions

View File

@ -6,6 +6,7 @@
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Docmost</title>
<!--meta-tags-->
</head>
<body>
<div id="root"></div>

View File

@ -62,6 +62,13 @@ export default function App() {
<>
<Routes>
<Route index element={<Navigate to="/home" />} />
<Route path={"/share/:id"} element={
<ErrorBoundary
fallback={<>Failed to load home. An error occurred.</>}
>
<Home />
</ErrorBoundary>
}/>
<Route path={"/login"} element={<LoginPage />} />
<Route path={"/invites/:invitationId"} element={<InviteSignup />} />
<Route path={"/setup/register"} element={<SetupWorkspace />} />

View File

@ -1,5 +1,8 @@
import { Controller, Get } from '@nestjs/common';
import { Controller, Get, Param, Res } from '@nestjs/common';
import { AppService } from './app.service';
import { FastifyReply } from "fastify";
import { join } from 'path';
import * as fs from 'node:fs';
@Controller()
export class AppController {
@ -9,4 +12,27 @@ export class AppController {
getHello(): string {
return this.appService.getHello();
}
@Get('/share/:id')
getShare(@Res({ passthrough: false}) res: FastifyReply, @Param() params: any): string {
const clientDistPath = join(
__dirname,
'..',
'..',
'client/dist',
);
if (fs.existsSync(clientDistPath)) {
console.log('exists')
const indexFilePath = join(clientDistPath, 'index.html');
const stream = fs.createReadStream(indexFilePath);
console.log(params.id)
res.type('text/html').send(stream);
console.log('found');
return;
}
console.log('end')
return this.appService.getHello();
}
}

View File

@ -24,7 +24,7 @@ async function bootstrap() {
},
);
app.setGlobalPrefix('api');
app.setGlobalPrefix('api', { exclude: ['share/:id']});
const redisIoAdapter = new WsRedisIoAdapter(app);
await redisIoAdapter.connectToRedis();