feat(auth): extend API key authentication to tRPC endpoints (#4732)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c8ecf5f0a1
commit
0dc61a88b8
10 files changed
+246
-72
No files matched your search
@@ -0,0 +1,15 @@
|
||||
import { userAgent as userAgentNextServer } from "next/server";
|
||||
|
||||
import type { Modify } from "./types";
|
||||
|
||||
export const userAgent = (headers: Headers) => {
|
||||
return userAgentNextServer({ headers }) as Omit<ReturnType<typeof userAgentNextServer>, "device"> & {
|
||||
device: Modify<ReturnType<typeof userAgentNextServer>["device"], { type: DeviceType }>;
|
||||
};
|
||||
};
|
||||
|
||||
export type DeviceType = "console" | "mobile" | "tablet" | "smarttv" | "wearable" | "embedded" | undefined;
|
||||
|
||||
export const ipAddressFromHeaders = (headers: Headers): string | null => {
|
||||
return headers.get("x-forwarded-for");
|
||||
};
|
||||
Reference in new issue
Block a user