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 { getPresignGetUrl } from '@documenso/lib/universal/upload/server-actions';
|
||||||
import { openApiDocument } from '@documenso/trpc/server/open-api';
|
import { openApiDocument } from '@documenso/trpc/server/open-api';
|
||||||
|
|
||||||
import { appMiddleware } from './middleware';
|
|
||||||
import { openApiTrpcServerHandler } from './trpc/hono-trpc-open-api';
|
import { openApiTrpcServerHandler } from './trpc/hono-trpc-open-api';
|
||||||
import { reactRouterTrpcServer } from './trpc/hono-trpc-remix';
|
import { reactRouterTrpcServer } from './trpc/hono-trpc-remix';
|
||||||
|
|
||||||
const app = new Hono();
|
const app = new Hono();
|
||||||
|
|
||||||
// App middleware.
|
// App middleware.
|
||||||
app.use('*', appMiddleware);
|
// app.use('*', appMiddleware);
|
||||||
|
|
||||||
// Auth server.
|
// Auth server.
|
||||||
app.route('/api/auth', auth);
|
app.route('/api/auth', auth);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export async function getLoadContext(args: GetLoadContextArgs) {
|
|||||||
|
|
||||||
const noSessionCookie = extractSessionCookieFromHeaders(request.headers) === null;
|
const noSessionCookie = extractSessionCookieFromHeaders(request.headers) === null;
|
||||||
|
|
||||||
if (!isPageRequest(request) || noSessionCookie) {
|
if (!isPageRequest(request) || noSessionCookie || blacklistedPathsRegex.test(url.pathname)) {
|
||||||
logger.log('Pathname ignored', url.pathname);
|
logger.log('Pathname ignored', url.pathname);
|
||||||
|
|
||||||
return {
|
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 team: TGetTeamByUrlResponse | null = null;
|
||||||
let teams: TGetTeamsResponse = [];
|
let teams: TGetTeamsResponse = [];
|
||||||
@@ -78,6 +78,7 @@ const isPageRequest = (request: Request) => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If it ends with .data it's the loader which we need to pass context for.
|
||||||
if (url.pathname.endsWith('.data')) {
|
if (url.pathname.endsWith('.data')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -88,3 +89,10 @@ const isPageRequest = (request: Request) => {
|
|||||||
|
|
||||||
return false;
|
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