fix(auth/sso): SsoButton href utilise VITE_API_URL pour fonctionner en dev
En dev le SPA tourne sur :5173 et l'API sur :3333. Un href relatif `/api/v1/auth/google/redirect` tape Vite (404). On préfixe par `env.VITE_API_URL` (http://localhost:3333 en dev, https://app... en prod où nginx reverse-proxy /api/* — donc l'URL est self-referential et fonctionne dans les deux cas). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
7521e1fff6
commit
ec2232e4b3
@ -1,4 +1,5 @@
|
|||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
import { env } from "@/lib/env";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bouton SSO réutilisable (Google, Microsoft, …).
|
* Bouton SSO réutilisable (Google, Microsoft, …).
|
||||||
@ -8,9 +9,9 @@ import { cn } from "@/lib/utils";
|
|||||||
* l'écran de consentement du provider avec ses cookies). Un fetch ne
|
* l'écran de consentement du provider avec ses cookies). Un fetch ne
|
||||||
* peut pas suivre les redirections cross-origin avec cookies.
|
* peut pas suivre les redirections cross-origin avec cookies.
|
||||||
*
|
*
|
||||||
* L'URL est relative — nginx (rubis-web) proxy /api/* vers rubis-api,
|
* L'URL est construite avec VITE_API_URL pour fonctionner aussi bien
|
||||||
* donc même origine pour le browser → cookie refresh posé par la
|
* en dev (http://localhost:3333) qu'en prod (https://app.rubis...) où
|
||||||
* callback est lisible côté SPA.
|
* nginx reverse-proxy /api/* vers le service rubis-api.
|
||||||
*/
|
*/
|
||||||
type SsoProvider = "google" | "microsoft";
|
type SsoProvider = "google" | "microsoft";
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ export function SsoButton({
|
|||||||
const Logo = LOGOS[provider];
|
const Logo = LOGOS[provider];
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
href={`/api/v1/auth/${provider}/redirect`}
|
href={`${env.VITE_API_URL}/api/v1/auth/${provider}/redirect`}
|
||||||
className={cn(
|
className={cn(
|
||||||
"inline-flex items-center justify-center gap-2.5 w-full",
|
"inline-flex items-center justify-center gap-2.5 w-full",
|
||||||
"h-11 px-5 rounded-default border border-line bg-white",
|
"h-11 px-5 rounded-default border border-line bg-white",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user