fix: redirect /board/* from jeffemmett.com to canvas.jeffemmett.com
When visiting jeffemmett.com/board/mycofi, the redirect now correctly goes to canvas.jeffemmett.com/mycofi/ instead of jeffemmett.com/mycofi. Localhost and canvas.jeffemmett.com still use same-domain redirects. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
35c8ae74c7
commit
b510558b5e
10
src/App.tsx
10
src/App.tsx
|
|
@ -89,10 +89,18 @@ const OptionalAuthRoute = ({ children }: { children: React.ReactNode }) => {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to redirect /board/:slug URLs to clean /:slug/ URLs
|
* Component to redirect /board/:slug URLs to clean /:slug/ URLs
|
||||||
* Used on staging to support both old and new URL patterns
|
* On non-canvas hostnames (e.g. jeffemmett.com), redirects to canvas.jeffemmett.com/:slug/
|
||||||
|
* On canvas.jeffemmett.com, does a same-domain redirect to /:slug/
|
||||||
*/
|
*/
|
||||||
const RedirectBoardSlug = () => {
|
const RedirectBoardSlug = () => {
|
||||||
const { slug } = useParams<{ slug: string }>();
|
const { slug } = useParams<{ slug: string }>();
|
||||||
|
const canvasHost = 'canvas.jeffemmett.com';
|
||||||
|
|
||||||
|
if (window.location.hostname !== canvasHost && window.location.hostname !== 'localhost') {
|
||||||
|
window.location.replace(`https://${canvasHost}/${slug}/`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return <Navigate to={`/${slug}/`} replace />;
|
return <Navigate to={`/${slug}/`} replace />;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue