From ec28eaa4ca49d9d8aaf368e5d6c608354d3ab2f4 Mon Sep 17 00:00:00 2001 From: theodesp <328805+theodesp@users.noreply.github.com> Date: Thu, 7 Mar 2024 15:28:49 +0000 Subject: [PATCH] Bug Fix: Fix wierd issue with import in experimental-app-router --- .../src/server/routeHandler/index.ts | 3 ++- .../src/server/routeHandler/tokenHandler.ts | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/experimental-app-router/src/server/routeHandler/index.ts b/packages/experimental-app-router/src/server/routeHandler/index.ts index 20f8eaacb..9246d825a 100644 --- a/packages/experimental-app-router/src/server/routeHandler/index.ts +++ b/packages/experimental-app-router/src/server/routeHandler/index.ts @@ -1,4 +1,5 @@ import { notFound } from 'next/navigation.js'; +import * as server from 'next/server.js'; import { tokenHandler } from './tokenHandler.js'; export async function GetFn(req: Request) { @@ -6,7 +7,7 @@ export async function GetFn(req: Request) { switch (pathname) { case '/api/faust/token': { - return tokenHandler(req); + return tokenHandler(req, server); } default: { return notFound(); diff --git a/packages/experimental-app-router/src/server/routeHandler/tokenHandler.ts b/packages/experimental-app-router/src/server/routeHandler/tokenHandler.ts index e0ceb8f30..03d252c52 100644 --- a/packages/experimental-app-router/src/server/routeHandler/tokenHandler.ts +++ b/packages/experimental-app-router/src/server/routeHandler/tokenHandler.ts @@ -1,5 +1,5 @@ import { cookies } from 'next/headers.js'; -import { NextResponse } from 'next/server.js'; +import * as server from 'next/server.js'; import { getWpUrl, getWpSecret } from '../../faust-core-utils.js'; export type AuthorizeResponse = { @@ -9,7 +9,7 @@ export type AuthorizeResponse = { refreshTokenExpiration: number; }; -export async function tokenHandler(req: Request) { +export async function tokenHandler(req: Request, s: typeof server) { try { const secretKey = getWpSecret(); @@ -79,7 +79,7 @@ export async function tokenHandler(req: Request) { * and expiration. */ - const res = new NextResponse(JSON.stringify(data), { + const res = new s.NextResponse(JSON.stringify(data), { status: 200, });