Skip to content

Commit d8d159b

Browse files
committed
Nick:
1 parent 4d8f410 commit d8d159b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

apps/api/src/controllers/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export async function supaAuthenticateUser(
206206
} else {
207207
rateLimiter = getRateLimiter(RateLimiterMode.Preview, token);
208208
}
209-
teamId = "preview";
209+
teamId = `preview_${iptoken}`;
210210
plan = "free";
211211
} else {
212212
normalizedApi = parseApi(token);
@@ -332,7 +332,7 @@ export async function supaAuthenticateUser(
332332
mode === RateLimiterMode.Extract ||
333333
mode === RateLimiterMode.Search)
334334
) {
335-
return { success: true, team_id: "preview", chunk: null, plan: "free" };
335+
return { success: true, team_id: `preview_${iptoken}`, chunk: null, plan: "free" };
336336
// check the origin of the request and make sure its from firecrawl.dev
337337
// const origin = req.headers.origin;
338338
// if (origin && origin.includes("firecrawl.dev")){

apps/api/src/controllers/v0/crawlPreview.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ export async function crawlPreviewController(req: Request, res: Response) {
2222
try {
2323
const auth = await authenticateUser(req, res, RateLimiterMode.Preview);
2424

25-
const team_id = "preview";
25+
const incomingIP = (req.headers["x-forwarded-for"] ||
26+
req.socket.remoteAddress) as string;
27+
const iptoken = incomingIP + "this_is_just_a_preview_token";
28+
const team_id = `preview_${iptoken}`;
2629

2730
if (!auth.success) {
2831
return res.status(auth.status).json({ error: auth.error });

0 commit comments

Comments
 (0)