Fixed shortlink redirections
This commit is contained in:
@@ -7,17 +7,14 @@ const { path } = Astro.params;
|
|||||||
// 2. Check for our loop-breaker
|
// 2. Check for our loop-breaker
|
||||||
const isLooping = Astro.url.searchParams.get('noloop') === 'true';
|
const isLooping = Astro.url.searchParams.get('noloop') === 'true';
|
||||||
|
|
||||||
// 3. Define the shortlink target (ensuring we don't double the slash)
|
// 3. SERVER-SIDE REDIRECT LOGIC
|
||||||
const shortlinkUrl = `https://upiecep.org/${path || ''}`;
|
|
||||||
|
|
||||||
// 4. SERVER-SIDE REDIRECT LOGIC
|
|
||||||
// If we didn't come from Short.io (noloop is missing), bounce back to the shortener once.
|
|
||||||
if (!isLooping) {
|
if (!isLooping) {
|
||||||
return Astro.redirect(shortlinkUrl);
|
// We inline the URL here. This removes the "unused variable" warning
|
||||||
|
// and keeps the logic tight.
|
||||||
|
return Astro.redirect(`https://upiecep.org/${path || ''}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. If we reach here, it's a confirmed 404 (Short.io already checked).
|
// 4. If we reach here, it's a confirmed 404 (Short.io already checked).
|
||||||
// Manually set the response status to 404 for SEO purposes.
|
|
||||||
Astro.response.status = 404;
|
Astro.response.status = 404;
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -33,7 +30,6 @@ Astro.response.status = 404;
|
|||||||
|
|
||||||
<div class="button-group">
|
<div class="button-group">
|
||||||
<a href="/" class="btn-main">Go to Homepage</a>
|
<a href="/" class="btn-main">Go to Homepage</a>
|
||||||
<!-- a href={shortlinkUrl} class="btn-shortlink">Try {shortlinkUrl}</a> -->
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|||||||
Reference in New Issue
Block a user