This commit is contained in:
Nicolas 2025-01-25 15:03:09 -03:00
parent 4d8f4109b5
commit d8d159b268
2 changed files with 6 additions and 3 deletions

View File

@ -206,7 +206,7 @@ export async function supaAuthenticateUser(
} else { } else {
rateLimiter = getRateLimiter(RateLimiterMode.Preview, token); rateLimiter = getRateLimiter(RateLimiterMode.Preview, token);
} }
teamId = "preview"; teamId = `preview_${iptoken}`;
plan = "free"; plan = "free";
} else { } else {
normalizedApi = parseApi(token); normalizedApi = parseApi(token);
@ -332,7 +332,7 @@ export async function supaAuthenticateUser(
mode === RateLimiterMode.Extract || mode === RateLimiterMode.Extract ||
mode === RateLimiterMode.Search) mode === RateLimiterMode.Search)
) { ) {
return { success: true, team_id: "preview", chunk: null, plan: "free" }; return { success: true, team_id: `preview_${iptoken}`, chunk: null, plan: "free" };
// check the origin of the request and make sure its from firecrawl.dev // check the origin of the request and make sure its from firecrawl.dev
// const origin = req.headers.origin; // const origin = req.headers.origin;
// if (origin && origin.includes("firecrawl.dev")){ // if (origin && origin.includes("firecrawl.dev")){

View File

@ -22,7 +22,10 @@ export async function crawlPreviewController(req: Request, res: Response) {
try { try {
const auth = await authenticateUser(req, res, RateLimiterMode.Preview); const auth = await authenticateUser(req, res, RateLimiterMode.Preview);
const team_id = "preview"; const incomingIP = (req.headers["x-forwarded-for"] ||
req.socket.remoteAddress) as string;
const iptoken = incomingIP + "this_is_just_a_preview_token";
const team_id = `preview_${iptoken}`;
if (!auth.success) { if (!auth.success) {
return res.status(auth.status).json({ error: auth.error }); return res.status(auth.status).json({ error: auth.error });