Spaces:
Running
Running
free requests stuffs
Browse files
app/api/ask-ai/route.ts
CHANGED
|
@@ -64,11 +64,9 @@ export async function POST(request: NextRequest) {
|
|
| 64 |
token = process.env.HF_TOKEN;
|
| 65 |
}
|
| 66 |
|
| 67 |
-
const ip =
|
| 68 |
-
authHeaders.get("x-forwarded-for")?.split(",")[
|
| 69 |
-
authHeaders.get("x-
|
| 70 |
-
"0.0.0.0";
|
| 71 |
-
console.log(request.headers);
|
| 72 |
|
| 73 |
if (!token) {
|
| 74 |
ipAddresses.set(ip, (ipAddresses.get(ip) || 0) + 1);
|
|
@@ -248,10 +246,9 @@ export async function PUT(request: NextRequest) {
|
|
| 248 |
token = process.env.HF_TOKEN;
|
| 249 |
}
|
| 250 |
|
| 251 |
-
const ip =
|
| 252 |
-
authHeaders.get("x-forwarded-for")?.split(",")[
|
| 253 |
-
authHeaders.get("x-
|
| 254 |
-
"0.0.0.0";
|
| 255 |
|
| 256 |
if (!token) {
|
| 257 |
ipAddresses.set(ip, (ipAddresses.get(ip) || 0) + 1);
|
|
|
|
| 64 |
token = process.env.HF_TOKEN;
|
| 65 |
}
|
| 66 |
|
| 67 |
+
const ip = authHeaders.get("x-forwarded-for")?.includes(",")
|
| 68 |
+
? authHeaders.get("x-forwarded-for")?.split(",")[1].trim()
|
| 69 |
+
: authHeaders.get("x-forwarded-for");
|
|
|
|
|
|
|
| 70 |
|
| 71 |
if (!token) {
|
| 72 |
ipAddresses.set(ip, (ipAddresses.get(ip) || 0) + 1);
|
|
|
|
| 246 |
token = process.env.HF_TOKEN;
|
| 247 |
}
|
| 248 |
|
| 249 |
+
const ip = authHeaders.get("x-forwarded-for")?.includes(",")
|
| 250 |
+
? authHeaders.get("x-forwarded-for")?.split(",")[1].trim()
|
| 251 |
+
: authHeaders.get("x-forwarded-for");
|
|
|
|
| 252 |
|
| 253 |
if (!token) {
|
| 254 |
ipAddresses.set(ip, (ipAddresses.get(ip) || 0) + 1);
|
components/contexts/app-context.tsx
CHANGED
|
@@ -41,7 +41,6 @@ export default function AppContext({
|
|
| 41 |
const events: any = {};
|
| 42 |
|
| 43 |
useBroadcastChannel("auth", (message) => {
|
| 44 |
-
console.log("Received message from auth channel:", message);
|
| 45 |
if (pathname.includes("/auth/callback")) return;
|
| 46 |
|
| 47 |
if (!message.code) return;
|
|
|
|
| 41 |
const events: any = {};
|
| 42 |
|
| 43 |
useBroadcastChannel("auth", (message) => {
|
|
|
|
| 44 |
if (pathname.includes("/auth/callback")) return;
|
| 45 |
|
| 46 |
if (!message.code) return;
|
components/editor/ask-ai/index.tsx
CHANGED
|
@@ -101,7 +101,6 @@ export function AskAI({
|
|
| 101 |
headers: {
|
| 102 |
"Content-Type": "application/json",
|
| 103 |
"x-forwarded-for": window.location.hostname,
|
| 104 |
-
"x-real-ip": window.location.hostname,
|
| 105 |
},
|
| 106 |
signal: abortController.signal,
|
| 107 |
});
|
|
@@ -141,7 +140,6 @@ export function AskAI({
|
|
| 141 |
headers: {
|
| 142 |
"Content-Type": "application/json",
|
| 143 |
"x-forwarded-for": window.location.hostname,
|
| 144 |
-
"x-real-ip": window.location.hostname,
|
| 145 |
},
|
| 146 |
signal: abortController.signal,
|
| 147 |
});
|
|
|
|
| 101 |
headers: {
|
| 102 |
"Content-Type": "application/json",
|
| 103 |
"x-forwarded-for": window.location.hostname,
|
|
|
|
| 104 |
},
|
| 105 |
signal: abortController.signal,
|
| 106 |
});
|
|
|
|
| 140 |
headers: {
|
| 141 |
"Content-Type": "application/json",
|
| 142 |
"x-forwarded-for": window.location.hostname,
|
|
|
|
| 143 |
},
|
| 144 |
signal: abortController.signal,
|
| 145 |
});
|