Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specifying a default callbackUrl on the server #1052

Closed
kripod opened this issue Jan 5, 2021 · 2 comments
Closed

Specifying a default callbackUrl on the server #1052

kripod opened this issue Jan 5, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@kripod
Copy link
Contributor

kripod commented Jan 5, 2021

Summary of proposed feature

The default value of callbackUrl should be specifiable securely as an option on the server.

Purpose of proposed feature

While the client-side signIn function provides a dynamic, location-based fallback for callbackUrl, an API call to /api/auth/signin/* has process.env.NEXTAUTH_URL hardcoded as the fallback value.

Detail about proposed feature

import type { NextApiRequest, NextApiResponse } from "next";
import NextAuth, { InitOptions } from "next-auth";

const options: InitOptions = {
  pages: {
    // `process.env.NEXTAUTH_URL` could be prepended automatically
    defaultCallback: "/auth/callback",
  },
};

export default (req: NextApiRequest, res: NextApiResponse) =>
  NextAuth(req, res, options);

Potential problems

There could be a mismatch between the client and the server by introducing a new defaultCallback URL on the server. The client shouldn’t infer a callbackUrl (based on window.location) after this feature is implemented.

@kripod kripod added the enhancement New feature or request label Jan 5, 2021
@jasonkuhrt
Copy link

This looks like a duplicate of #969

@kripod
Copy link
Contributor Author

kripod commented Jan 6, 2021

@jasonkuhrt Thanks for pointing this out, I’m closing this in favor of that issue.

@kripod kripod closed this as completed Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants