fix(demo): POST waitlist to canonical www host to avoid preflight redirect
The demo (demo.pcbjam.com) cross-posts the waitlist to the marketing site's
serverless endpoint. It targeted the apex pcbjam.com, which 308-redirects to
www on Vercel; a CORS preflight can't follow redirects, so the OPTIONS failed
("Redirect is not allowed for a preflight request") and the POST never landed.
Point the waitlist target at the canonical www host. www.pcbjam.com already
returns 204 with access-control-allow-origin: https://demo.pcbjam.com, so the
preflight passes. Landing/version-badge link stays on the apex.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01REwWZGkAz1AZUJw8yqxkCN
This commit is contained in:
parent
e86be160a6
commit
34d2602132
3 changed files with 15 additions and 4 deletions
|
|
@ -58,7 +58,14 @@ function parseArgs(argv) {
|
||||||
a.cdn = a.cdn.replace(/\/+$/, "");
|
a.cdn = a.cdn.replace(/\/+$/, "");
|
||||||
a.repo = a.repo.replace(/\/+$/, "");
|
a.repo = a.repo.replace(/\/+$/, "");
|
||||||
a.landing = a.landing.replace(/\/+$/, "");
|
a.landing = a.landing.replace(/\/+$/, "");
|
||||||
a.waitlist = a.waitlist || `${a.landing}/api/waitlist`;
|
// The cross-origin demo POSTs the waitlist to the marketing site's serverless
|
||||||
|
// endpoint. The apex (pcbjam.com) 308-redirects to www on Vercel, and a CORS
|
||||||
|
// preflight can't follow redirects, so the demo must hit the canonical www host
|
||||||
|
// directly. Derive from --landing for custom/staging hosts, but pin the
|
||||||
|
// production apex to www. (Landing/version-badge link stays on the apex.)
|
||||||
|
const waitlistHost =
|
||||||
|
a.landing === "https://pcbjam.com" ? "https://www.pcbjam.com" : a.landing;
|
||||||
|
a.waitlist = a.waitlist || `${waitlistHost}/api/waitlist`;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,13 @@ VITE_WASM_ROOT=/wasm
|
||||||
# Marketing / landing page the version badge links to (default https://pcbjam.com).
|
# Marketing / landing page the version badge links to (default https://pcbjam.com).
|
||||||
# VITE_LANDING_URL=https://pcbjam.com
|
# VITE_LANDING_URL=https://pcbjam.com
|
||||||
|
|
||||||
# Where the in-editor waitlist form POSTs (default https://pcbjam.com/api/waitlist).
|
# Where the in-editor waitlist form POSTs (default https://www.pcbjam.com/api/waitlist).
|
||||||
# The demo is static with no backend, so it cross-posts to the landing site's
|
# The demo is static with no backend, so it cross-posts to the landing site's
|
||||||
# serverless endpoint, which must send CORS for this origin (see
|
# serverless endpoint, which must send CORS for this origin (see
|
||||||
# site/src/pages/api/waitlist.ts). Same JSON contract {email, source, company_url}.
|
# site/src/pages/api/waitlist.ts). Same JSON contract {email, source, company_url}.
|
||||||
# VITE_WAITLIST_URL=https://pcbjam.com/api/waitlist
|
# Use the canonical www host: the apex 308-redirects to www and a CORS preflight
|
||||||
|
# can't follow redirects.
|
||||||
|
# VITE_WAITLIST_URL=https://www.pcbjam.com/api/waitlist
|
||||||
|
|
||||||
# Plausible analytics. Unset ⇒ no tracking (dev/checkout default). Set the
|
# Plausible analytics. Unset ⇒ no tracking (dev/checkout default). Set the
|
||||||
# data-domain to enable; override the script URL only if the default plausible.io
|
# data-domain to enable; override the script URL only if the default plausible.io
|
||||||
|
|
|
||||||
|
|
@ -54,9 +54,11 @@ export const LANDING_URL = (
|
||||||
* Where the in-editor waitlist form POSTs. The demo is a fully static deploy with
|
* Where the in-editor waitlist form POSTs. The demo is a fully static deploy with
|
||||||
* no backend, so it cross-posts to the landing site's serverless endpoint (which
|
* no backend, so it cross-posts to the landing site's serverless endpoint (which
|
||||||
* sends CORS for this origin). Same JSON contract as site/src/pages/api/waitlist.ts.
|
* sends CORS for this origin). Same JSON contract as site/src/pages/api/waitlist.ts.
|
||||||
|
* Targets the canonical www host: the apex 308-redirects to www on Vercel, and a
|
||||||
|
* CORS preflight can't follow a redirect (so the apex would break the POST).
|
||||||
*/
|
*/
|
||||||
export const WAITLIST_URL =
|
export const WAITLIST_URL =
|
||||||
import.meta.env.VITE_WAITLIST_URL || "https://pcbjam.com/api/waitlist";
|
import.meta.env.VITE_WAITLIST_URL || "https://www.pcbjam.com/api/waitlist";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plausible analytics (privacy-friendly, cookieless). Off unless a domain is set
|
* Plausible analytics (privacy-friendly, cookieless). Off unless a domain is set
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue