diff --git a/node_modules/@blitzjs/auth/dist/next-auth.cjs b/node_modules/@blitzjs/auth/dist/next-auth.cjs index f7b02a2..ca30d39 100644 --- a/node_modules/@blitzjs/auth/dist/next-auth.cjs +++ b/node_modules/@blitzjs/auth/dist/next-auth.cjs @@ -22,7 +22,7 @@ require('http'); require('jsonwebtoken'); require('net'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; } +function _interopDefaultLegacy(e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; } const cookieSession__default = /*#__PURE__*/_interopDefaultLegacy(cookieSession); const getAuthorizationUrl__default = /*#__PURE__*/_interopDefaultLegacy(getAuthorizationUrl); @@ -97,7 +97,7 @@ function toInternalRequest(req) { if (!action) { throw new blitz.OAuthError("Cannot detect action."); } - const providerIdOrAction = pathname.split("/").pop(); + const providerIdOrAction = pathname.split("/").pop() === action ? pathname.split("/").at(-2) : pathname.split("/").pop(); let providerId; if (providerIdOrAction && !action.includes(providerIdOrAction) && ["login", "callback"].includes(action)) { providerId = providerIdOrAction; @@ -305,7 +305,7 @@ function NextAuthAdapter(config) { if (!((_a = req.query.nextauth) == null ? void 0 : _a.length)) { return res.status(404).end(); } - const action = req.query.nextauth[1]; + const action = ["login", "callback"].includes(req.query.nextauth[1]) ? req.query.nextauth[1] : req.query.nextauth[0]; if (!action || !["login", "callback"].includes(action)) { return res.status(404).end(); } @@ -358,7 +358,10 @@ function NextAuthAdapter(config) { cookies: internalRequest.cookies, isPost: req.method === "POST" }); - options.provider.callbackUrl = switchURL(options.provider.callbackUrl); + const test_url = new URL(options.provider.callbackUrl) + test_url.pathname = `/api/auth/${action}/${providerId}` + options.provider.callbackUrl = action === "callback" && test_url.pathname === req.url.split("?").shift() ? test_url.toString() : switchURL(options.provider.callbackUrl); + // options.provider.callbackUrl = switchURL(test_url.toString()) blitz.log.debug("NEXT_AUTH_INTERNAL_OPTIONS", options); yield AuthHandler(middleware, config, internalRequest, action, options, cookies).then((_0) => __async(this, [_0], function* ({ middleware: middleware2 }) { yield blitz.handleRequestWithMiddleware(