Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/core/src/lib/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import url from 'url'
import path from 'path'
import path from 'node:path'

import type express from 'express'
import type next from 'next'
import type { KeystoneContext, KeystoneConfig } from '../types'
import { pkgDir } from '../pkg-dir'
import type { KeystoneConfig, KeystoneContext } from '../types'

const adminErrorHTMLFilepath = path.join(pkgDir, 'static', 'admin-error.html')

Expand All @@ -21,7 +21,7 @@ export function createAdminUIMiddlewareWithNextApp(
if (basePath.endsWith('/')) throw new TypeError('basePath must not end with a trailing slash')

return async (req: express.Request, res: express.Response) => {
const { pathname } = url.parse(req.url)
const { pathname } = new URL(req.url, 'http://ks')

if (pathname?.startsWith(`${basePath}/_next`) || pathname?.startsWith(`${basePath}/__next`)) {
return handle(req, res)
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/scripts/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import fsp from 'node:fs/promises'
import { createServer } from 'node:http'
import type { ListenOptions } from 'node:net'
import path from 'node:path'
import url from 'node:url'

import { createDatabase } from '@prisma/internals'
import chalk from 'chalk'
Expand Down Expand Up @@ -393,7 +392,7 @@ export async function dev(
return expressServer(req, res, next)
}

const { pathname } = url.parse(req.url)
const { pathname } = new URL(req.url, 'http://ks')
if (expressServer && pathname === (config.graphql?.path ?? '/api/graphql')) {
return expressServer(req, res, next)
}
Expand Down
Loading