Disable initial page that re-directs to /login

Hello,

i’m currently achieving a slow re-direct, to avoid need to press the only Login button on the inital page

import { apiInitializer } from "discourse/lib/api";

export default apiInitializer("1.0", (api) => {
  api.onPageChange((url) => {
    const user = api.getCurrentUser();

    let path = url?.startsWith("http") ? new URL(url).pathname : url;
    path = path?.replace(/\/+$/, "") || "/";

    const allowedAnonPaths = ["/login", "/privacy", "/tos", "/pub/about-this-forum", "/safe-mode", "/pub/accessibility-statement"];

    if (!user && !allowedAnonPaths.includes(path)) {
      window.location.href = "/login";
    }
  });
});

this excludes paths where i don’t want traffic to be re-directed from.


This isn’t ideal, but is currently in use on https://physicswithethan.discourse.diy

Pretty sure Discourse is already doing that for you. If it’s not working, then something’s wrong with your setup :thinking:

Hmm, I see a login button you need to click first here:

But I never was annoyed by that. I don’t think being taken to an input form without seeing where you are would be a better experience. There is less knformation about where you are here:

Right :man_facepalming: I forgot we edge-cased the “home-page”… All the other pages should immediately show the login page instead. Maybe it should be a setting :thinking:

@pmusaraj do you remember why we edge-cased the home page?

Yeah, most login-required sites benefit from having that landing screen. For example, they’ll have signup / login buttons if signups are available. And a place to describe the community before showing the form.

We do offer skipping this screen in one narrow use case: when the site has only one external login method, via this setting:

turns out that setting was enabled on https://physicswithethan.discourse.diy

so i’ve not changed any settings since before starting this topic