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