Skip to content

Commit

Permalink
redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbuechele committed Sep 13, 2024
1 parent 10a910d commit edc51d1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 15 deletions.
48 changes: 34 additions & 14 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import {getDataFromTree} from '@apollo/client/react/ssr';
import {createSitemapGenerator} from 'remix-sitemap';
import * as Sentry from '@sentry/remix';

const siteUrl = 'www.kulturspektakel.de';

const {isSitemapUrl, sitemap} = createSitemapGenerator({
siteUrl: 'https://www.kulturspektakel.de',
siteUrl: 'https://' + siteUrl,
generateRobotsTxt: true,
});

Expand All @@ -28,21 +30,39 @@ export default async function handleRequest(
responseHeaders: Headers,
remixContext: EntryContext,
) {
if (isSitemapUrl(request)) {
return await sitemap(request, remixContext);
}

const url = new URL(request.url);
if (KULT_CASH_PATH_PREFIXES.has(url.pathname.split('/')?.at(1))) {
if (url.hostname === 'kult.cash') {
// we are good
} else if (url.hostname === 'localhost') {
console.warn(
`Accessing ${url.pathname} in production is only possible via kult.cash`,
);
} else {
return new Response('Not Found', {status: 404});
if (url.hostname === 'kult.cash') {
if (url.pathname === '/robots.txt') {
return new Response('Disallow: /', {
status: 200,
headers: {
'Content-Type': 'text/plain',
},
});
} else if (!KULT_CASH_PATH_PREFIXES.has(url.pathname.split('/')?.at(1))) {
url.hostname = siteUrl;
return new Response('Redirecting...', {
status: 301,
headers: {
Location: url.toString(),
},
});
}
} else if (
url.hostname !== 'localhost' &&
KULT_CASH_PATH_PREFIXES.has(url.pathname.split('/')?.at(1))
) {
url.hostname = 'kult.cash';
return new Response('Redirecting...', {
status: 301,
headers: {
Location: url.toString(),
},
});
}

if (isSitemapUrl(request)) {
return await sitemap(request, remixContext);
}

const App = <RemixServer context={remixContext} url={request.url} />;
Expand Down
10 changes: 9 additions & 1 deletion app/routes/[$$].$hash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,15 @@ export default function () {
const data = useTypedLoaderData<typeof loader>();

return (
<VStack maxW="450" mr="auto" ml="auto" spacing="7" align="stretch">
<VStack
maxW="450"
mr="auto"
ml="auto"
spacing="7"
minH="calc(100vh - 148px)"
align="stretch"
justifyContent="center"
>
{data.hasNewerTransactions && (
<InfoBox>
Es liegen neuere Buchungen vor. Karte erneut auslesen um diese
Expand Down

0 comments on commit edc51d1

Please sign in to comment.