chore: update live chat and work server changes
This commit is contained in:
@@ -148,7 +148,22 @@ function canViewAllConversations(request: { headers: Record<string, unknown> })
|
||||
return hasErrorLogViewAccessToken(request.headers['x-access-token'] as string | string[] | undefined);
|
||||
}
|
||||
|
||||
function applyChatApiNoStoreHeaders(reply: FastifyReply) {
|
||||
reply.header('Cache-Control', 'no-store, no-cache, max-age=0, must-revalidate');
|
||||
reply.header('Pragma', 'no-cache');
|
||||
reply.header('Expires', '0');
|
||||
reply.header('Surrogate-Control', 'no-store');
|
||||
}
|
||||
|
||||
export async function registerChatRoutes(app: FastifyInstance) {
|
||||
app.addHook('onSend', async (request, reply, payload) => {
|
||||
if (request.method.toUpperCase() === 'GET' && request.url.startsWith('/api/chat')) {
|
||||
applyChatApiNoStoreHeaders(reply);
|
||||
}
|
||||
|
||||
return payload;
|
||||
});
|
||||
|
||||
app.get(`${CHAT_PUBLIC_ROUTE_PREFIX}*`, async (request, reply) => {
|
||||
const wildcard = String((request.params as { '*': string | undefined })['*'] ?? '').trim();
|
||||
return serveChatPublicResource(resolveChatAttachmentRepoPath(), wildcard, reply);
|
||||
|
||||
Reference in New Issue
Block a user