From a3b9cd71adcd187671e9b57b24a45a187b24b4cf Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 20 Jan 2026 19:02:24 +0700 Subject: [PATCH] sign up download flow --- .../apps/artcraft-website/src/app/app.tsx | 10 ++ .../src/components/auth/index.ts | 1 + .../src/components/auth/signup-form.tsx | 153 ++++++++++++++++ .../discord-button/discord-button.tsx | 2 +- .../src/components/download-modal.tsx | 153 ++++++++++++++++ .../src/components/navbar/navbar.tsx | 163 ++++++++++++++++-- .../pages/forgot-password/forgot-password.tsx | 72 ++++++++ .../src/pages/forgot-password/index.ts | 2 + .../src/pages/landing2/landing2.tsx | 96 ++++++++--- .../artcraft-website/src/pages/login/index.ts | 2 + .../src/pages/login/login.tsx | 132 ++++++++++++++ .../src/pages/pricing/index.ts | 2 + .../src/pages/pricing/pricing.tsx | 123 +++++++++++++ .../src/pages/signup/index.ts | 2 + .../src/pages/signup/signup.tsx | 40 +++++ .../src/pages/welcome/index.ts | 2 + .../src/pages/welcome/welcome.tsx | 138 +++++++++++++++ .../apps/artcraft-website/tailwind.config.js | 3 +- frontend/apps/artcraft-website/vite.config.ts | 3 + frontend/libs/api/src/lib/UsersApi.ts | 18 +- 20 files changed, 1067 insertions(+), 50 deletions(-) create mode 100644 frontend/apps/artcraft-website/src/components/auth/index.ts create mode 100644 frontend/apps/artcraft-website/src/components/auth/signup-form.tsx create mode 100644 frontend/apps/artcraft-website/src/components/download-modal.tsx create mode 100644 frontend/apps/artcraft-website/src/pages/forgot-password/forgot-password.tsx create mode 100644 frontend/apps/artcraft-website/src/pages/forgot-password/index.ts create mode 100644 frontend/apps/artcraft-website/src/pages/login/index.ts create mode 100644 frontend/apps/artcraft-website/src/pages/login/login.tsx create mode 100644 frontend/apps/artcraft-website/src/pages/pricing/index.ts create mode 100644 frontend/apps/artcraft-website/src/pages/pricing/pricing.tsx create mode 100644 frontend/apps/artcraft-website/src/pages/signup/index.ts create mode 100644 frontend/apps/artcraft-website/src/pages/signup/signup.tsx create mode 100644 frontend/apps/artcraft-website/src/pages/welcome/index.ts create mode 100644 frontend/apps/artcraft-website/src/pages/welcome/welcome.tsx diff --git a/frontend/apps/artcraft-website/src/app/app.tsx b/frontend/apps/artcraft-website/src/app/app.tsx index d4517b1c4d..0acbde1389 100644 --- a/frontend/apps/artcraft-website/src/app/app.tsx +++ b/frontend/apps/artcraft-website/src/app/app.tsx @@ -9,6 +9,11 @@ import TutorialsArticle from "../pages/tutorials/article"; import FaqIndex from "../pages/faq/index"; import FaqArticle from "../pages/faq/article"; import { NewsIndex, NewsPost } from "@storyteller/markdown-content"; +import Pricing from "../pages/pricing"; +import Login from "../pages/login"; +import Signup from "../pages/signup"; +import ForgotPassword from "../pages/forgot-password"; +import Welcome from "../pages/welcome"; export function App() { return ( @@ -27,6 +32,11 @@ export function App() { } /> } /> } /> + } /> + } /> + } /> + } /> + } /> ); diff --git a/frontend/apps/artcraft-website/src/components/auth/index.ts b/frontend/apps/artcraft-website/src/components/auth/index.ts new file mode 100644 index 0000000000..6ad600f9af --- /dev/null +++ b/frontend/apps/artcraft-website/src/components/auth/index.ts @@ -0,0 +1 @@ +export * from "./signup-form"; diff --git a/frontend/apps/artcraft-website/src/components/auth/signup-form.tsx b/frontend/apps/artcraft-website/src/components/auth/signup-form.tsx new file mode 100644 index 0000000000..1a06c7b523 --- /dev/null +++ b/frontend/apps/artcraft-website/src/components/auth/signup-form.tsx @@ -0,0 +1,153 @@ +import { faGoogle } from "@fortawesome/free-brands-svg-icons"; +import { faEye, faEyeSlash, faSpinner } from "@fortawesome/pro-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { Button } from "@storyteller/ui-button"; +import { useState } from "react"; +import { UsersApi } from "@storyteller/api"; + +interface SignupFormProps { + onSuccess: () => void; + signupSource: string; + className?: string; + showGoogleButton?: boolean; + autoFocus?: boolean; +} + +export const SignupForm = ({ + onSuccess, + signupSource, + className = "", + showGoogleButton = true, + autoFocus = false, +}: SignupFormProps) => { + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [showPassword, setShowPassword] = useState(false); + + const [isLoading, setIsLoading] = useState(false); + const [error, setError] = useState(null); + + const handleSignup = async () => { + setError(null); + + if (!email || !password) { + setError("All fields are required"); + return; + } + + if (password.length < 8) { + setError("Password must be at least 8 characters"); + return; + } + + setIsLoading(true); + + const api = new UsersApi(); + + // Generate a username from the email + const emailPrefix = email.split("@")[0].replace(/[^a-zA-Z0-9]/g, ""); + // Ensure we don't exceed max length (7 chars from email + 3 digits = 10 total) + const truncatedPrefix = emailPrefix.substring(0, 7); + const randomSuffix = Math.floor(Math.random() * 900) + 100; // 100-999 + const generatedUsername = `${truncatedPrefix}${randomSuffix}`; + + const response = await api.Signup({ + username: generatedUsername, + email, + password, + passwordConfirmation: password, + signupSource, + }); + + setIsLoading(false); + + if (response.success) { + window.dispatchEvent(new Event("auth-change")); + onSuccess(); + } else { + setError(response.errorMessage || "Failed to create account"); + } + }; + + return ( +
+ {showGoogleButton && ( + <> + + +
+
+
+
+ + or + +
+ + )} + + {error && ( +
+ {error} +
+ )} + +
+ + setEmail(e.target.value)} + placeholder="you@example.com" + autoFocus={autoFocus} + className="w-full bg-black/20 border border-white/10 focus:border-primary/50 rounded-xl px-4 py-3 text-white placeholder-white/20 outline-none transition-colors" + onKeyDown={(e) => e.key === "Enter" && handleSignup()} + /> +
+ +
+ +
+ setPassword(e.target.value)} + placeholder="Min. 8 characters" + className="w-full bg-black/20 border border-white/10 focus:border-primary/50 rounded-xl px-4 py-3 text-white placeholder-white/20 outline-none transition-colors pr-12" + onKeyDown={(e) => e.key === "Enter" && handleSignup()} + /> + +
+
+ + +
+ ); +}; diff --git a/frontend/apps/artcraft-website/src/components/discord-button/discord-button.tsx b/frontend/apps/artcraft-website/src/components/discord-button/discord-button.tsx index cb1d49564f..c75a791511 100644 --- a/frontend/apps/artcraft-website/src/components/discord-button/discord-button.tsx +++ b/frontend/apps/artcraft-website/src/components/discord-button/discord-button.tsx @@ -17,7 +17,7 @@ export const DiscordButton = ({ return ( + + {view === "signup" && ( + + )} + +
+
+ + + +
+

+ Downloading ArtCraft... +

+

+ Your download has started. +
+ While you wait, create an account to store your creations. +

+
+ + {view === "menu" ? ( +
+ + + +
+ ) : ( + { + onClose(); + navigate("/welcome"); + }} + signupSource="artcraft" + showGoogleButton={false} + autoFocus={true} + /> + )} + +
+ +
+ + , + document.body, + ); +}; diff --git a/frontend/apps/artcraft-website/src/components/navbar/navbar.tsx b/frontend/apps/artcraft-website/src/components/navbar/navbar.tsx index afb56eeb4c..5c7a23ec51 100644 --- a/frontend/apps/artcraft-website/src/components/navbar/navbar.tsx +++ b/frontend/apps/artcraft-website/src/components/navbar/navbar.tsx @@ -1,8 +1,16 @@ -import { Disclosure } from "@headlessui/react"; +import { + Disclosure, + Menu, + MenuButton, + MenuItem, + MenuItems, + Transition, +} from "@headlessui/react"; import { twMerge } from "tailwind-merge"; -import { useEffect, useState } from "react"; +import { useEffect, useState, Fragment } from "react"; import { Link, useLocation } from "react-router-dom"; -import { DiscordButton } from "../discord-button"; +import { Button } from "@storyteller/ui-button"; +import { UsersApi, UserInfo } from "@storyteller/api"; const NAV_ITEMS = [ { name: "Home", href: "/" }, @@ -10,12 +18,51 @@ const NAV_ITEMS = [ { name: "News", href: "/news" }, { name: "FAQ", href: "/faq" }, { name: "Press Kit", href: "/press-kit" }, + { name: "Download", href: "/download" }, ]; export default function Navbar() { const [scrolled, setScrolled] = useState(false); const location = useLocation(); - // Underline hover handled purely via CSS + const [user, setUser] = useState(undefined); + const [isLoading, setIsLoading] = useState(true); + + // Check session on mount + // Check session on mount and when auth changes or location changes + useEffect(() => { + const checkSession = async () => { + const api = new UsersApi(); + const response = await api.GetSession(); + if ( + response.success && + response.data && + response.data.loggedIn && + response.data.user + ) { + setUser(response.data.user); + } else { + setUser(undefined); + } + setIsLoading(false); + }; + + checkSession(); + + const handleAuthChange = () => { + setIsLoading(true); + checkSession(); + }; + + window.addEventListener("auth-change", handleAuthChange); + return () => window.removeEventListener("auth-change", handleAuthChange); + }, [location.pathname]); + + const handleLogout = async () => { + const api = new UsersApi(); + await api.Logout(); + // Reload to clear state/cache + window.location.href = "/"; + }; useEffect(() => { const handleScroll = () => { @@ -89,21 +136,99 @@ export default function Navbar() {
-
- {/* */} - -
-
- {/* Mobile menu button */} - + {isLoading ? ( + // Loading placeholder +
+ ) : user ? ( + // Logged In State +
+ + Pricing + + + +
+ + Open user menu + + +
+ + +
+

+ {user.display_name || user.username} +

+
+ + {({ active }) => ( + + )} + +
+
+
+
+ ) : ( + // Logged Out State +
+ + Pricing + + +
+ )} + + {/* Mobile Menu Button - simplified for now */} +
+ {!user && ( + + )} + {user && ( + + )}
diff --git a/frontend/apps/artcraft-website/src/pages/forgot-password/forgot-password.tsx b/frontend/apps/artcraft-website/src/pages/forgot-password/forgot-password.tsx new file mode 100644 index 0000000000..97d76efe30 --- /dev/null +++ b/frontend/apps/artcraft-website/src/pages/forgot-password/forgot-password.tsx @@ -0,0 +1,72 @@ +import { faArrowLeft, faEnvelope } from "@fortawesome/pro-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { Button } from "@storyteller/ui-button"; +import { useState } from "react"; +import { Link } from "react-router-dom"; + +const ForgotPassword = () => { + const [email, setEmail] = useState(""); + const [submitted, setSubmitted] = useState(false); + + return ( +
+
+ +
+
+
+

Reset Password

+

Enter your email to receive reset instructions

+
+ + {!submitted ? ( +
+
+ + setEmail(e.target.value)} + placeholder="you@example.com" + className="w-full bg-black/20 border border-white/10 focus:border-primary/50 rounded-xl px-4 py-3 text-white placeholder-white/20 outline-none transition-colors" + /> +
+ + +
+ ) : ( +
+
+ +
+

Check your email

+

+ We've sent a password reset link to
{email} +

+ +
+ )} + +
+ + Back to Log in + +
+ +
+
+
+ ); +}; + +export default ForgotPassword; diff --git a/frontend/apps/artcraft-website/src/pages/forgot-password/index.ts b/frontend/apps/artcraft-website/src/pages/forgot-password/index.ts new file mode 100644 index 0000000000..6fa87516c8 --- /dev/null +++ b/frontend/apps/artcraft-website/src/pages/forgot-password/index.ts @@ -0,0 +1,2 @@ +import ForgotPassword from "./forgot-password"; +export default ForgotPassword; diff --git a/frontend/apps/artcraft-website/src/pages/landing2/landing2.tsx b/frontend/apps/artcraft-website/src/pages/landing2/landing2.tsx index 920a782730..5d2836a2cc 100644 --- a/frontend/apps/artcraft-website/src/pages/landing2/landing2.tsx +++ b/frontend/apps/artcraft-website/src/pages/landing2/landing2.tsx @@ -1,6 +1,6 @@ import { DiscordButton } from "../../components/discord-button"; import { Button } from "@storyteller/ui-button"; -import { isMobile } from "react-device-detect"; +import { isMobile, isMacOs } from "react-device-detect"; import { faWindows, faApple, faGithub } from "@fortawesome/free-brands-svg-icons"; import { faVolumeMute, @@ -25,6 +25,8 @@ import ModelBadgeGrid from "../../components/model-badge-grid"; import Seo from "../../components/seo"; import { DOWNLOAD_LINKS } from "../../config/downloads"; import { OwnershipComparison } from "../../components/ownership-comparison/ownership-comparison"; +import { DownloadModal } from "../../components/download-modal"; +import { UsersApi } from "@storyteller/api"; gsap.registerPlugin(ScrollTrigger); @@ -52,8 +54,33 @@ const Landing = () => { const [isHovering, setIsHovering] = useState(false); const [activeFeature, setActiveFeature] = useState(0); const [activeVideo, setActiveVideo] = useState(null); + const [showDownloadModal, setShowDownloadModal] = useState(false); + const [isLoggedIn, setIsLoggedIn] = useState(false); const videoRef = useRef(null); + const downloadUrl = isMacOs ? MAC_LINK : WINDOWS_LINK; + + useEffect(() => { + const checkSession = async () => { + const api = new UsersApi(); + const response = await api.GetSession(); + if (response.success && response.data?.loggedIn) { + setIsLoggedIn(true); + } + }; + checkSession(); + }, []); + + const onDownloadClick = (e: React.MouseEvent) => { + if (isLoggedIn) { + return; + } + + setShowDownloadModal(true); + + localStorage.setItem("artcraft_download_initiated", "true"); + }; + const features = [ { icon: faMapMarkerAlt, @@ -263,26 +290,17 @@ const Landing = () => { Download on a desktop ) : ( - <> - - - + )} - Try Free + Try Free
{/* Glassy Video Mockup */} @@ -773,13 +791,13 @@ const Landing = () => {
{/* Discord CTA Section */}
-

+

Join the Discord

-

+

Connect with other creators, share your work, get feedback, and stay updated.

@@ -807,9 +825,41 @@ const Landing = () => { Star on GitHub
+ + + {/* Download CTA Section - New */} +
+
+
+ +

+ Ready to Create? +

+

+ Join thousands of artists and filmmakers using ArtCraft to bring their vision to life. +

+ +
+ +
Free to use.
+
Unlimited Nano Banana Pro for a limited time!
+
+
+ setShowDownloadModal(false)} />
); diff --git a/frontend/apps/artcraft-website/src/pages/login/index.ts b/frontend/apps/artcraft-website/src/pages/login/index.ts new file mode 100644 index 0000000000..e5d0293db8 --- /dev/null +++ b/frontend/apps/artcraft-website/src/pages/login/index.ts @@ -0,0 +1,2 @@ +import LogIn from "./login"; +export default LogIn; diff --git a/frontend/apps/artcraft-website/src/pages/login/login.tsx b/frontend/apps/artcraft-website/src/pages/login/login.tsx new file mode 100644 index 0000000000..95643aa385 --- /dev/null +++ b/frontend/apps/artcraft-website/src/pages/login/login.tsx @@ -0,0 +1,132 @@ +import { faGoogle } from "@fortawesome/free-brands-svg-icons"; +import { faEye, faEyeSlash, faSpinner } from "@fortawesome/pro-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { Button } from "@storyteller/ui-button"; +import { useState } from "react"; +import { Link, useNavigate } from "react-router-dom"; +import { UsersApi } from "@storyteller/api"; + +const Login = () => { + const navigate = useNavigate(); + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [showPassword, setShowPassword] = useState(false); + + const [isLoading, setIsLoading] = useState(false); + const [error, setError] = useState(null); + + const handleLogin = async () => { + setError(null); + setIsLoading(true); + + const api = new UsersApi(); + const response = await api.Login({ + usernameOrEmail: email, + password: password + }); + + setIsLoading(false); + + if (response.success) { + window.dispatchEvent(new Event('auth-change')); + navigate("/"); + } else { + setError(response.errorMessage || "Invalid credentials"); + } + }; + + return ( +
+
+ +
+
+
+

Welcome Back

+

Log in to your account

+
+ +
+ + +
+
+
+
+ or +
+ +
+ {error && ( +
+ {error} +
+ )} + +
+ + setEmail(e.target.value)} + placeholder="you@example.com or username" + className="w-full bg-black/20 border border-white/10 focus:border-primary/50 rounded-xl px-4 py-3 text-white placeholder-white/20 outline-none transition-colors" + /> +
+
+
+ + Forgot password? +
+
+ setPassword(e.target.value)} + placeholder="Min. 8 characters" + className="w-full bg-black/20 border border-white/10 focus:border-primary/50 rounded-xl px-4 py-3 text-white placeholder-white/20 outline-none transition-colors pr-12" + /> + +
+
+ + +
+
+ +
+ Don't have an account?{" "} + + Sign up + +
+ +
+
+ +
+ © {new Date().getFullYear()} ArtCraft. All rights reserved. +
+
+ ); +}; + +export default Login; diff --git a/frontend/apps/artcraft-website/src/pages/pricing/index.ts b/frontend/apps/artcraft-website/src/pages/pricing/index.ts new file mode 100644 index 0000000000..0d05fe37de --- /dev/null +++ b/frontend/apps/artcraft-website/src/pages/pricing/index.ts @@ -0,0 +1,2 @@ +import Pricing from "./pricing"; +export default Pricing; diff --git a/frontend/apps/artcraft-website/src/pages/pricing/pricing.tsx b/frontend/apps/artcraft-website/src/pages/pricing/pricing.tsx new file mode 100644 index 0000000000..1af9555eae --- /dev/null +++ b/frontend/apps/artcraft-website/src/pages/pricing/pricing.tsx @@ -0,0 +1,123 @@ +import { faCheck } from "@fortawesome/pro-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { Button } from "@storyteller/ui-button"; +import Footer from "../../components/footer"; + +const Pricing = () => { + return ( +
+
+
+
+
+ +
+
+

+ Simple, Transparent Pricing +

+

+ Start for free and scale as you grow. No hidden fees. +

+
+ +
+ {/* Free Tier */} +
+

Hobbyist

+
+ $0 + /month +
+

+ Perfect for getting started and learning the basics of ArtCraft. +

+ +
    + + + + +
+
+ + {/* Pro Tier (Highlighted) */} +
+
+ MOST POPULAR +
+

Pro

+
+ $20 + /month +
+

+ For professional artists and creators who need more power. +

+ +
    + + + + + + +
+
+ + {/* Studio Tier */} +
+

Studio

+
+ $100 + /month +
+

+ For teams and studios requiring collaboration tools. +

+ +
    + + + + + +
+
+ +
+
+ +
+
+ ); +}; + +const Feature = ({ text, highlighted = false }: { text: string; highlighted?: boolean }) => ( +
  • +
    + +
    + {text} +
  • +); + +export default Pricing; diff --git a/frontend/apps/artcraft-website/src/pages/signup/index.ts b/frontend/apps/artcraft-website/src/pages/signup/index.ts new file mode 100644 index 0000000000..53aa30bc54 --- /dev/null +++ b/frontend/apps/artcraft-website/src/pages/signup/index.ts @@ -0,0 +1,2 @@ +import SignUp from "./signup"; +export default SignUp; diff --git a/frontend/apps/artcraft-website/src/pages/signup/signup.tsx b/frontend/apps/artcraft-website/src/pages/signup/signup.tsx new file mode 100644 index 0000000000..6a2a1b5a20 --- /dev/null +++ b/frontend/apps/artcraft-website/src/pages/signup/signup.tsx @@ -0,0 +1,40 @@ +import { Link, useNavigate } from "react-router-dom"; +import { SignupForm } from "../../components/auth"; + +const Signup = () => { + const navigate = useNavigate(); + + return ( +
    +
    + +
    +
    +
    +

    Create an Account

    +

    Join thousands of creators

    +
    + + navigate("/welcome")} + signupSource="artcraft" + /> + +
    + Already have an account?{" "} + + Log in + +
    + +
    +
    + +
    + © {new Date().getFullYear()} ArtCraft. All rights reserved. +
    +
    + ); +}; + +export default Signup; diff --git a/frontend/apps/artcraft-website/src/pages/welcome/index.ts b/frontend/apps/artcraft-website/src/pages/welcome/index.ts new file mode 100644 index 0000000000..00ff1ec952 --- /dev/null +++ b/frontend/apps/artcraft-website/src/pages/welcome/index.ts @@ -0,0 +1,2 @@ +import Welcome from "./welcome"; +export default Welcome; diff --git a/frontend/apps/artcraft-website/src/pages/welcome/welcome.tsx b/frontend/apps/artcraft-website/src/pages/welcome/welcome.tsx new file mode 100644 index 0000000000..f3f3ab90a0 --- /dev/null +++ b/frontend/apps/artcraft-website/src/pages/welcome/welcome.tsx @@ -0,0 +1,138 @@ +import { + faCheckCircle, + faDownload, + faDesktop, + faRocket, +} from "@fortawesome/pro-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { Button } from "@storyteller/ui-button"; +import { Link } from "react-router-dom"; +import { isMobile, isMacOs } from "react-device-detect"; +import { DOWNLOAD_LINKS } from "../../config/downloads"; + +const Welcome = () => { + const downloadUrl = isMacOs ? DOWNLOAD_LINKS.MACOS : DOWNLOAD_LINKS.WINDOWS; + + return ( +
    +
    +
    +
    +

    + +
    + Welcome to ArtCraft +
    +

    + +

    + Your account is ready. Let's get you set up to create. +

    + +
    + {/* Information Column */} +
    +
    +

    Next Steps

    +
    + +
    +
    +
    + 1 +
    +
    + Open the installer +
    +
    +
    +
    + 2 +
    +
    + Follow setup instructions +
    +
    +
    +
    + 3 +
    +
    + Log in to account +
    +
    +
    +
    + 4 +
    +
    + Start creating! +
    +
    +
    +
    +
    + + {/* Contingency / Action Area */} + {!isMobile && ( +
    +

    + Download didn't start? +

    + + +
    + )} + + {isMobile && ( +
    +
    + +
    + ArtCraft is a powerful desktop experience.
    + Please head to your computer to download and install. +
    + )} +
    + + {/* Footer of Card */} +
    + + Back to Home + +
    +
    +
    +
    + ); +}; + +export default Welcome; diff --git a/frontend/apps/artcraft-website/tailwind.config.js b/frontend/apps/artcraft-website/tailwind.config.js index 13f05a4542..338f8fca06 100644 --- a/frontend/apps/artcraft-website/tailwind.config.js +++ b/frontend/apps/artcraft-website/tailwind.config.js @@ -7,7 +7,7 @@ module.exports = { content: [ join( __dirname, - "{src,pages,components,app}/**/*!(*.stories|*.spec).{ts,tsx,html}" + "{src,pages,components,app}/**/*!(*.stories|*.spec).{ts,tsx,html}", ), ...createGlobPatternsForDependencies(__dirname), "./app/index.html", @@ -23,6 +23,7 @@ module.exports = { white: colors.white, gray: colors.gray, black: colors.black, + red: colors.red, blue: colors.blue, orange: colors.orange, green: colors.green, diff --git a/frontend/apps/artcraft-website/vite.config.ts b/frontend/apps/artcraft-website/vite.config.ts index 0c25fe6437..4df77c2536 100644 --- a/frontend/apps/artcraft-website/vite.config.ts +++ b/frontend/apps/artcraft-website/vite.config.ts @@ -32,6 +32,9 @@ export default defineConfig(() => ({ target: 'https://api.storyteller.ai', changeOrigin: true, secure: true, + headers: { + Origin: 'https://api.storyteller.ai', + }, }, }, }, diff --git a/frontend/libs/api/src/lib/UsersApi.ts b/frontend/libs/api/src/lib/UsersApi.ts index 72ce5e9aaf..1bfc1e880d 100644 --- a/frontend/libs/api/src/lib/UsersApi.ts +++ b/frontend/libs/api/src/lib/UsersApi.ts @@ -8,7 +8,7 @@ interface SignupRequest { password: string; password_confirmation: string; signup_source?: string; -}; +} export class UsersApi extends ApiManager { private async authFetch( @@ -19,7 +19,7 @@ export class UsersApi extends ApiManager { }: { method: string; body?: B; - } + }, ): Promise { const bodyInString = JSON.stringify(body); @@ -33,8 +33,14 @@ export class UsersApi extends ApiManager { body: bodyInString, }); - const responseData = await response.json(); - return responseData as T; + const text = await response.text(); + try { + const responseData = JSON.parse(text); + return responseData as T; + } catch (e) { + console.error("Failed to parse response as JSON:", text); + throw new Error(text || `Request failed with status ${response.status}`); + } } public GetSession(): Promise< @@ -164,7 +170,7 @@ export class UsersApi extends ApiManager { signupSource?: string; }): Promise> { const endpoint = `${this.getApiSchemeAndHost()}/v1/create_account`; - const body : SignupRequest = { + const body: SignupRequest = { email_address: email, password, password_confirmation: passwordConfirmation, @@ -207,4 +213,4 @@ export class UsersApi extends ApiManager { } } -(window as any).UsersApi = new UsersApi(); \ No newline at end of file +(window as any).UsersApi = new UsersApi();