blitz-js / blitz

⚡️ The Missing Fullstack Toolkit for Next.js

Home Page:https://Blitzjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

getBlitzContext() can't be use in edge funcion

gengjiawen opened this issue · comments

What is the problem?

rt

Paste all your error logs here:

Attempted import error: 'setupBlitzServer' is not exported from '@blitzjs/next' (imported as 'setupBlitzServer').

Import trace for requested module:
./src/app/blitz-server.ts
./src/app/api/user/route.ts
./node_modules/.pnpm/next@13.5.4_@babel+core@7.23.9_react-dom@18.2.0_react@18.2.0_sass@1.71.1/node_modules/next/dist/build/webpack/loaders/next-app-loader.js?name=app%2Fapi%2Fuser%2Froute&page=%2Fapi%2Fuser%2Froute&appPaths=&pagePath=private-next-app-dir%2Fapi%2Fuser%2Froute.ts&appDir=%2Fworkspace%2Fai%2Fsrc%2Fapp&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&rootDir=%2Fworkspace%2Fai&isDev=true&tsconfigPath=tsconfig.json&basePath=&assetPrefix=&nextConfigOutput=standalone&preferredRegion=&middlewareConfig=e30%3D!./src/app/api/user/route.ts?__next_edge_ssr_entry__

./src/app/blitz-server.ts
Attempted import error: 'AuthServerPlugin' is not exported from '@blitzjs/auth' (imported as 'AuthServerPlugin').

Import trace for requested module:
./src/app/blitz-server.ts
./src/app/api/user/route.ts
./node_modules/.pnpm/next@13.5.4_@babel+core@7.23.9_react-dom@18.2.0_react@18.2.0_sass@1.71.1/node_modules/next/dist/build/webpack/loaders/next-app-loader.js?name=app%2Fapi%2Fuser%2Froute&page=%2Fapi%2Fuser%2Froute&appPaths=&pagePath=private-next-app-dir%2Fapi%2Fuser%2Froute.ts&appDir=%2Fworkspace%2Fai%2Fsrc%2Fapp&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&rootDir=%2Fworkspace%2Fai&isDev=true&tsconfigPath=tsconfig.json&basePath=&assetPrefix=&nextConfigOutput=standalone&preferredRegion=&middlewareConfig=e30%3D!./src/app/api/user/route.ts?__next_edge_ssr_entry__

Paste all relevant code snippets here:

import { NextRequest, NextResponse } from "next/server"
import { getBlitzContext } from "../../blitz-server"

export async function GET(request: NextRequest) {
  const ctx = await getBlitzContext()
  if (!ctx.session.userId) {
    return new Response("Unauthorized", { status: 401 })
  }

  return NextResponse.json({
    userId: ctx.session.userId,
  })
}


export const runtime = "edge"```


### What are detailed steps to reproduce this?

1.

### Run `blitz -v` and paste the output here:

PASTE_HERE (leave the ``` marks)



### Please include below any other applicable logs and screenshots that show your problem:

_No response_

thanks for the issue @gengjiawen. This is being worked on.