Commit c8276472 authored by Grant's avatar Grant
Browse files

Fix login button (CORS)

parent fb62dd17
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -32,14 +32,11 @@ export const Palette = () => {
  }, []);

  const handleLogin = useCallback(() => {
    fetch("/api/login", {
      redirect: "manual",
    }).then(async (res) => {
      const location = res.headers.get("location");
      if (location) {
        window.location.href = location;
      } else {
    fetch("/api/login").then(async (res) => {
      const data = await res.json();
      if (data.success) {
        window.location.href = data.redirect;
      } else {
        if ("error" in data) {
          toast.error("Error while logging in: " + data.error);
        }
+4 −1
Original line number Diff line number Diff line
@@ -12,7 +12,10 @@ export const AuthEndpoints = Router();
 */
AuthEndpoints.get("/login", (req, res) => {
  try {
    res.redirect(OpenIDController.get().getAuthorizationURL());
    res.json({
      success: true,
      redirect: OpenIDController.get().getAuthorizationURL(),
    });
  } catch (e) {
    if (e instanceof InvalidAuthMode) {
      res.status(400).json({