From 6ae14ae3a10d79e5f0b70b1b1af74e8a3507bb83 Mon Sep 17 00:00:00 2001 From: Tradam Date: Thu, 16 May 2024 15:22:12 -0400 Subject: isolate serving of user HTML files to a seperate domain --- app/javascript/components/Layout.jsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app/javascript/components') diff --git a/app/javascript/components/Layout.jsx b/app/javascript/components/Layout.jsx index 30d1086..79e7813 100644 --- a/app/javascript/components/Layout.jsx +++ b/app/javascript/components/Layout.jsx @@ -5,6 +5,18 @@ export default function Layout ({userData}) { console.log(userData); //const [userData, setUserData] = useState({ name: "" }); + + // if the user tries to access the isolated domain then we redirect them + // this is NOT done for security, only for good UX + // rails serves the react app no matter what + // so the app would be broken when served on the isolated domain + const domain = window.location.host; + console.log(domain); + if(domain === "localhost:3000") + { + window.location.replace("http://127.0.0.1:3000"); + } + return ( <>
-- cgit v1.2.3