Update Versi 1.5.27 #32

Merged
bagasbanuna merged 1009 commits from staging into main 2025-12-17 12:22:28 +08:00
1672 changed files with 70469 additions and 18716 deletions
Showing only changes of commit fa69f3a929 - Show all commits

View File

@@ -39,6 +39,7 @@
"autoprefixer": "10.4.14",
"bufferutil": "^4.0.8",
"bun": "^1.1.38",
"colors": "^1.4.0",
"date-fns": "^4.1.0",
"dayjs": "^1.11.10",
"dotenv": "^16.4.5",

View File

@@ -50,6 +50,7 @@
"autoprefixer": "10.4.14",
"bufferutil": "^4.0.8",
"bun": "^1.1.38",
"colors": "^1.4.0",
"date-fns": "^4.1.0",
"dayjs": "^1.11.10",
"dotenv": "^16.4.5",

View File

@@ -0,0 +1,15 @@
import { cookies } from "next/headers";
import "colors";
export async function GET(req: Request) {
// const token = req.headers.get("Authorizationx")?.split(" ")[1];
const token = cookies().get("hipmi-key")?.value;
return new Response(token, {
status: 200,
headers: {
"Content-Type": "application/json",
"Cache-Control": "no-store",
},
});
}

View File

@@ -1,11 +1,8 @@
import { NextResponse } from "next/server";
export async function GET(req: Request) {
const auth = req.headers.get("Authorization");
const token = auth?.split(" ")[1];
console.log("Token received in API Validation:", token , `<<<<<<<<<<<<<<<`);
console.log("Authorization header:", auth, `<--------`);
const token = req.headers.get("Authorization")?.split(" ")[1];
console.log("Token received in API Validation:", token, `<<<<<<<<<<<<<<<`);
if (!token) return NextResponse.json({ success: false }, { status: 401 });

View File

@@ -1,5 +1,7 @@
import { jwtVerify } from "jose";
import { NextRequest, NextResponse } from "next/server";
import { cookies } from "next/headers";
type MiddlewareConfig = {
apiPath: string;
@@ -75,6 +77,16 @@ export const middleware = async (req: NextRequest) => {
} = middlewareConfig;
const { pathname } = req.nextUrl;
// console.warn(cookies().get("hipmi-key")?.value);
// const f = await fetch("https://localhost:3000/api/middleware", {
// method: "GET",
// headers: {
// "Content-Type": "application/json",
// },
// });
// console.warn(await f.text())
// console.log("Cookies >>", req.cookies.get("hipmi-key")?.value);
// Handle CORS
const corsResponse = handleCors(req);
@@ -92,7 +104,7 @@ export const middleware = async (req: NextRequest) => {
const token = getToken(req, sessionKey);
const user = await verifyToken({ token, encodedKey });
console.log("Request URL:", req.url);
console.log("Request URL v2 >>", req.url);
// const fetchValidation = async (url: string) => {
// try {
@@ -151,9 +163,6 @@ export const middleware = async (req: NextRequest) => {
}
try {
// const validationResponse = await fetchValidation("/api/validation");
// console.log("Validation Response:", validationResponse);
// console.log("TOKEN >>", token);
const validationResponse = await fetch(
`${new URL(req.url).origin}/api/validation`,
{

5
x.sh Normal file
View File

@@ -0,0 +1,5 @@
TOKEN="eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjp7ImlkIjoiY20wYWUzcmw2MDAwMWZzNWowN3ZtdjRvaCIsIm5vbW9yIjoiNjI4MjM0MDM3NDQxMiIsInVzZXJuYW1lIjoiYmFnYXNfYWRtaW4iLCJhY3RpdmUiOnRydWUsIm1hc3RlclVzZXJSb2xlSWQiOiIzIn0sImlhdCI6MTc0Mjk2OTc1OSwiZXhwIjoxOTYzODcyOTU5fQ.4bFEdhm4TeysoDcC1D54PPbyJPHSMBisiEn5GXoYr30"
# curl -X GET -H "Authorization: Bearer $TOKEN" https://localhost:3000/api/middleware
curl -X GET -H "Cookie: hipmi-key=$TOKEN; user_id=789" https://localhost:3000/api/middleware