Compare commits

...

5 Commits

Author SHA1 Message Date
Balázs Orbán
b74bfc68e8 chore(release): bump package version(s) [skip ci] 2022-12-08 05:16:10 +01:00
Balázs Orbán
0a140cdf87 test(core): fix test 2022-12-08 05:11:37 +01:00
Balázs Orbán
157269e0fb fix(core): throw error if no action can be determined 2022-12-08 05:10:26 +01:00
Balázs Orbán
221bc8e99c fix(core): add protocol if missing 2022-12-08 04:54:42 +01:00
Balázs Orbán
f856363ac8 chore(release): bump package version(s) [skip ci] 2022-12-08 04:38:03 +01:00
3 changed files with 21 additions and 16 deletions

View File

@@ -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",

View File

@@ -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
}

View File

@@ -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 () => {