mirror of
https://github.com/SrIzan10/next-auth.git
synced 2026-05-01 10:55:20 +00:00
Compare commits
5 Commits
next-auth@
...
next-auth@
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b74bfc68e8 | ||
|
|
0a140cdf87 | ||
|
|
157269e0fb | ||
|
|
221bc8e99c | ||
|
|
f856363ac8 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "next-auth",
|
||||
"version": "4.18.1",
|
||||
"version": "4.18.3",
|
||||
"description": "Authentication for Next.js",
|
||||
"homepage": "https://next-auth.js.org",
|
||||
"repository": "https://github.com/nextauthjs/next-auth.git",
|
||||
|
||||
@@ -43,8 +43,12 @@ export function getURL(
|
||||
}
|
||||
|
||||
if (!host) throw new TypeError("Invalid host")
|
||||
if (!url) throw new TypeError("Invalid URL, cannot determine action")
|
||||
|
||||
return new URL(`${host}${url ?? ""}`)
|
||||
if (host.startsWith("http://") || host.startsWith("https://")) {
|
||||
return new URL(`${host}${url}`)
|
||||
}
|
||||
return new URL(`https://${host}${url}`)
|
||||
} catch (error) {
|
||||
return error as Error
|
||||
}
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
import { MissingAPIRoute } from "../src/core/errors"
|
||||
// import { MissingAPIRoute } from "../src/core/errors"
|
||||
import { nodeHandler } from "./utils"
|
||||
|
||||
it("Missing req.url throws MISSING_NEXTAUTH_API_ROUTE_ERROR", async () => {
|
||||
const { res, logger } = await nodeHandler()
|
||||
const { res } = await nodeHandler()
|
||||
|
||||
expect(res.status).toBeCalledWith(500)
|
||||
expect(logger.error).toBeCalledTimes(1)
|
||||
expect(logger.error).toBeCalledWith(
|
||||
"MISSING_NEXTAUTH_API_ROUTE_ERROR",
|
||||
expect.any(MissingAPIRoute)
|
||||
)
|
||||
expect(res.setHeader).toBeCalledWith("content-type", "application/json")
|
||||
const body = res.send.mock.calls[0][0]
|
||||
expect(JSON.parse(body)).toEqual({
|
||||
message:
|
||||
"There is a problem with the server configuration. Check the server logs for more information.",
|
||||
})
|
||||
expect(res.status).toBeCalledWith(400)
|
||||
// Moved to host detection in getUrl
|
||||
// expect(logger.error).toBeCalledTimes(1)
|
||||
// expect(logger.error).toBeCalledWith(
|
||||
// "MISSING_NEXTAUTH_API_ROUTE_ERROR",
|
||||
// expect.any(MissingAPIRoute)
|
||||
// )
|
||||
// expect(res.setHeader).toBeCalledWith("content-type", "application/json")
|
||||
// const body = res.send.mock.calls[0][0]
|
||||
// expect(JSON.parse(body)).toEqual({
|
||||
// message:
|
||||
// "There is a problem with the server configuration. Check the server logs for more information.",
|
||||
// })
|
||||
})
|
||||
|
||||
it("Missing host throws 400 in production", async () => {
|
||||
|
||||
Reference in New Issue
Block a user