Fix adds redirect callback that support app.cal.com (#2768)

* Fix adds redirect callback that support app.cal.com

* Update apps/web/pages/api/auth/[...nextauth].tsx

Check origin of website and baseurl

Co-authored-by: Omar López <[email protected]>

* fix: lint issue extra space removed

Co-authored-by: Agusti Fernandez Pardo <[email protected]>
Co-authored-by: Omar López <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2022-05-16 17:44:44 +00:00
1 parent e4c5df7a2e
commit 9c52e195ea
1 file changed
+7
@@ -434,5 +434,12 @@ export default NextAuth({
return false;
},
async redirect({ url, baseUrl }) {
// Allows relative callback URLs
if (url.startsWith("/")) return `${baseUrl}${url}`;
// Allows callback URLs on the same origin
else if (new URL(url).origin === new URL(baseUrl || WEBSITE_URL).origin) return url;
return baseUrl;
},
},
});