Show Google sign-in even when site.json isn't deployed
/api/auth/providers read site.json to build Google's return address, and the deploy copies server/ into /srv/ngu-api without site.json, so it threw and the login page hid the button. Whether Google is on now depends only on the client id and secret; a missing return address is logged when a sign-in starts, naming GOOGLE_REDIRECT_URI and SITE_CONFIG. The docs say how the server is actually deployed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d4b39251d9
commit
e932ee3007
4 changed files with 35 additions and 6 deletions
|
|
@ -10,7 +10,9 @@
|
|||
|
||||
GOOGLE_CLIENT_ID from Google Cloud Console
|
||||
GOOGLE_CLIENT_SECRET the same; never in the repo
|
||||
GOOGLE_REDIRECT_URI default <site.json url>/api/auth/google/callback
|
||||
GOOGLE_REDIRECT_URI default <site.json url>/api/auth/google/callback;
|
||||
set it when the server is deployed
|
||||
without site.json (SITE_CONFIG)
|
||||
GOOGLE_ALLOWED_DOMAIN default nextgenerationofunity.org
|
||||
|
||||
With no client id or secret it's off: the login page doesn't
|
||||
|
|
@ -45,10 +47,18 @@ export function googleConfig() {
|
|||
const clientSecret = process.env.GOOGLE_CLIENT_SECRET;
|
||||
if (!clientId || !clientSecret) return null;
|
||||
|
||||
let redirectUri = process.env.GOOGLE_REDIRECT_URI;
|
||||
// Whether Google is on depends only on the id and secret. The
|
||||
// return address can come from site.json, which a deploy of the
|
||||
// server alone may not have; that's reported where it's needed
|
||||
// (the sign-in routes), rather than hiding the button.
|
||||
let redirectUri = process.env.GOOGLE_REDIRECT_URI ?? null;
|
||||
if (!redirectUri) {
|
||||
const origin = (loadSite().url ?? "").replace(/\/$/, "");
|
||||
redirectUri = `${origin}/api/auth/google/callback`;
|
||||
try {
|
||||
const origin = (loadSite().url ?? "").replace(/\/$/, "");
|
||||
if (origin) redirectUri = `${origin}/api/auth/google/callback`;
|
||||
} catch {
|
||||
redirectUri = null;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue