|
|
|
@ -2,6 +2,7 @@ import { NextRequest } from "next/server";
|
|
|
|
|
import { getServerSideConfig } from "../config/server";
|
|
|
|
|
import md5 from "spark-md5";
|
|
|
|
|
import { ACCESS_CODE_PREFIX } from "../constant";
|
|
|
|
|
import { log } from "console";
|
|
|
|
|
|
|
|
|
|
function getIP(req: NextRequest) {
|
|
|
|
|
let ip = req.ip ?? req.headers.get("x-real-ip");
|
|
|
|
@ -49,6 +50,7 @@ export function auth(req: NextRequest) {
|
|
|
|
|
// if user does not provide an api key, inject system api key
|
|
|
|
|
if (!token) {
|
|
|
|
|
const apiKey = serverConfig.apiKey;
|
|
|
|
|
console.log("apiKey :>> ", apiKey);
|
|
|
|
|
if (apiKey) {
|
|
|
|
|
console.log("[Auth] use system api key");
|
|
|
|
|
req.headers.set("Authorization", `Bearer ${apiKey}`);
|
|
|
|
|