Skip to content

Commit 05d045b

Browse files
committed
dont use url.parse
1 parent 61d4277 commit 05d045b

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

packages/core/src/lib/middleware.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import url from 'url'
2-
import path from 'path'
1+
import path from 'node:path'
2+
33
import type express from 'express'
44
import type next from 'next'
5-
import type { KeystoneContext, KeystoneConfig } from '../types'
65
import { pkgDir } from '../pkg-dir'
6+
import type { KeystoneConfig, KeystoneContext } from '../types'
77

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

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

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

2626
if (pathname?.startsWith(`${basePath}/_next`) || pathname?.startsWith(`${basePath}/__next`)) {
2727
return handle(req, res)

packages/core/src/scripts/dev.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import fsp from 'node:fs/promises'
22
import { createServer } from 'node:http'
33
import type { ListenOptions } from 'node:net'
44
import path from 'node:path'
5-
import url from 'node:url'
65

76
import { createDatabase } from '@prisma/internals'
87
import chalk from 'chalk'
@@ -393,7 +392,7 @@ export async function dev(
393392
return expressServer(req, res, next)
394393
}
395394

396-
const { pathname } = url.parse(req.url)
395+
const { pathname } = new URL(req.url, 'http://ks')
397396
if (expressServer && pathname === (config.graphql?.path ?? '/api/graphql')) {
398397
return expressServer(req, res, next)
399398
}

0 commit comments

Comments
 (0)