Backend: add PUBLIC_BASE_PATH for NIP-98 URL behind /api proxy
Made-with: Cursor
This commit is contained in:
@@ -83,11 +83,12 @@ export async function nip98Auth(req: Request, res: Response, next: NextFunction)
|
||||
return;
|
||||
}
|
||||
|
||||
// Reconstruct absolute URL (protocol + host + path + query)
|
||||
// Reconstruct absolute URL (protocol + host + base path + path + query)
|
||||
const proto = (req.headers["x-forwarded-proto"] as string | undefined) ?? ((req.socket as { encrypted?: boolean }).encrypted ? "https" : "http");
|
||||
const host = (req.headers["x-forwarded-host"] as string | undefined) ?? req.headers.host ?? "";
|
||||
const path = req.originalUrl ?? req.url;
|
||||
const absoluteUrl = `${proto}://${host}${path}`;
|
||||
const basePath = config.publicBasePath ? `/${config.publicBasePath.replace(/^\//, "")}` : "";
|
||||
const absoluteUrl = `${proto}://${host}${basePath}${path}`;
|
||||
if (u !== absoluteUrl) {
|
||||
res.status(401).json({
|
||||
code: "invalid_nip98",
|
||||
|
||||
Reference in New Issue
Block a user