mirror of
https://github.com/documenso/documenso.git
synced 2025-11-10 04:22:32 +10:00
fix: wip
This commit is contained in:
@ -11,14 +11,13 @@ import { putFile } from '@documenso/lib/universal/upload/put-file';
|
||||
import { getPresignGetUrl } from '@documenso/lib/universal/upload/server-actions';
|
||||
import { openApiDocument } from '@documenso/trpc/server/open-api';
|
||||
|
||||
import { appMiddleware } from './middleware';
|
||||
import { openApiTrpcServerHandler } from './trpc/hono-trpc-open-api';
|
||||
import { reactRouterTrpcServer } from './trpc/hono-trpc-remix';
|
||||
|
||||
const app = new Hono();
|
||||
|
||||
// App middleware.
|
||||
app.use('*', appMiddleware);
|
||||
// app.use('*', appMiddleware);
|
||||
|
||||
// Auth server.
|
||||
app.route('/api/auth', auth);
|
||||
|
||||
@ -23,7 +23,7 @@ export async function getLoadContext(args: GetLoadContextArgs) {
|
||||
|
||||
const noSessionCookie = extractSessionCookieFromHeaders(request.headers) === null;
|
||||
|
||||
if (!isPageRequest(request) || noSessionCookie) {
|
||||
if (!isPageRequest(request) || noSessionCookie || blacklistedPathsRegex.test(url.pathname)) {
|
||||
logger.log('Pathname ignored', url.pathname);
|
||||
|
||||
return {
|
||||
@ -32,7 +32,7 @@ export async function getLoadContext(args: GetLoadContextArgs) {
|
||||
};
|
||||
}
|
||||
|
||||
const splitUrl = url.pathname.split('/');
|
||||
const splitUrl = url.pathname.replace('.data', '').split('/');
|
||||
|
||||
let team: TGetTeamByUrlResponse | null = null;
|
||||
let teams: TGetTeamsResponse = [];
|
||||
@ -78,6 +78,7 @@ const isPageRequest = (request: Request) => {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If it ends with .data it's the loader which we need to pass context for.
|
||||
if (url.pathname.endsWith('.data')) {
|
||||
return true;
|
||||
}
|
||||
@ -88,3 +89,10 @@ const isPageRequest = (request: Request) => {
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* List of paths to reject
|
||||
* - Urls that start with /api
|
||||
* - Urls that start with _
|
||||
*/
|
||||
const blacklistedPathsRegex = new RegExp('^/api/|^/__');
|
||||
|
||||
Reference in New Issue
Block a user