Reverse proxy
This commit is contained in:
parent
3ecd05e824
commit
00897ae0d9
@ -1,25 +0,0 @@
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
try {
|
||||
const body = await req.json();
|
||||
|
||||
const response = await fetch(
|
||||
"http://localhost:3001/auth/register",
|
||||
{
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(body),
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
const data = await response.json();
|
||||
return NextResponse.json(data, { status: response.status });
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
{ error: "Signup service not reachable" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
try {
|
||||
const body = await req.json();
|
||||
|
||||
const response = await fetch("http://localhost:3001/auth/signup", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
return NextResponse.json(data, { status: response.status });
|
||||
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
{ error: "Auth backend not reachable" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
37
app/api/sitemap/route.ts
Normal file
37
app/api/sitemap/route.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function GET(req: Request) {
|
||||
try {
|
||||
const { searchParams } = new URL(req.url);
|
||||
const u = searchParams.get("u");
|
||||
if (!u) return NextResponse.json({ error: "Missing ?u=" }, { status: 400 });
|
||||
|
||||
const target = new URL(u.match(/^https?:\/\//i) ? u : `https://${u}`);
|
||||
|
||||
// This is correct: no double-escaping
|
||||
const candidates: string[] = /\/sitemap(.*)\.xml$/i.test(target.pathname)
|
||||
? [target.toString()]
|
||||
: [
|
||||
new URL("/sitemap.xml", target.origin).toString(),
|
||||
new URL("/sitemap_index.xml", target.origin).toString(),
|
||||
];
|
||||
|
||||
// fetch & parse each candidate; you can also call your backend util if exposed
|
||||
const urls:any = new Set<string>();
|
||||
|
||||
|
||||
// very light probe: just check existence; swap to real parser if needed
|
||||
for (const href of candidates) {
|
||||
try {
|
||||
const r = await fetch(href, { headers: { "user-agent": "CrawlerX/1.0" }, cache: "no-store" });
|
||||
if (r.ok) urls.add(href);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
// If you want full expansion, call your backend endpoint instead of the above loop
|
||||
|
||||
return NextResponse.json({ ok: true, origin: target.origin, count: urls.size, urls: [...urls] });
|
||||
} catch (e: any) {
|
||||
return NextResponse.json({ error: e?.message || "Bad URL" }, { status: 400 });
|
||||
}
|
||||
}
|
||||
4328
package-lock.json
generated
4328
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user