I setup a Static Site to deploy my React app. Deploy worked and most of the functionality of the app is okey. However I have a catch-all redirect that allows non-existent URLs to redirect to the root “/”. For example a user visiting a non-existent route like “/asdsa” will redirect to “/”. This works when testing locally but it returns errors with a 404 on the hosted site in Render.
Do static sites allow external redirects? Below is a snippet of the external redirect component I wrote :
// ./src/components/ExternalRedirect.tsx
import { useEffect } from 'react';
const ExternalRedirect = ({ url }) => {
useEffect(() => {
window.location.href = url;
}, [url]);
return null;
};
export default ExternalRedirect;