mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-07 07:55:13 +02:00
ktx.sh/ and docs.ktx.sh/ redirected to https://docs.kaelio.com/ktx/ktx/docs/... (note the doubled /ktx) and 404'd. The host-agnostic `source: "/"` redirect ran before the alias-host canonicalizers, so it injected the /ktx basePath into the path on the alias domains, which the alias catch-all then prepended a second time. Reorder redirects() so alias-host canonicalization runs first, leaving the generic root/docs rules for the local/canonical host only. The /stars exclusion stays because redirects run before beforeFiles rewrites. Add Host-spoofing regression tests (the prior tests only used localhost, which never exercised the alias-host rules) and remove the vestigial website/vercel.json, which the live ktx.sh routing already bypasses. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
79 lines
2.3 KiB
JavaScript
79 lines
2.3 KiB
JavaScript
import { createMDX } from "fumadocs-mdx/next";
|
|
|
|
const withMDX = createMDX();
|
|
|
|
/** @type {import('next').NextConfig} */
|
|
const config = {
|
|
basePath: "/ktx",
|
|
async rewrites() {
|
|
return {
|
|
beforeFiles: [
|
|
{
|
|
source: "/stars",
|
|
has: [{ type: "host", value: "ktx.sh" }],
|
|
destination: "https://ktx-stars.vercel.app/stars",
|
|
basePath: false,
|
|
},
|
|
{
|
|
source: "/stars/:path*",
|
|
has: [{ type: "host", value: "ktx.sh" }],
|
|
destination: "https://ktx-stars.vercel.app/stars/:path*",
|
|
basePath: false,
|
|
},
|
|
],
|
|
afterFiles: [
|
|
{
|
|
source: "/docs/:path*.md",
|
|
destination: "/llms.mdx/docs/:path*",
|
|
},
|
|
],
|
|
};
|
|
},
|
|
async redirects() {
|
|
// Alias-host canonicalization MUST come before the generic root/docs
|
|
// redirects below. Those generic rules have no host guard, so if they ran
|
|
// first they would inject a "/ktx" basePath into the path on the alias
|
|
// hosts, which the alias catch-alls would then prepend a second time —
|
|
// producing https://docs.kaelio.com/ktx/ktx/docs/... Redirects also run
|
|
// before beforeFiles rewrites, so the ktx.sh catch-all must exclude
|
|
// /stars* to let the stars dashboard rewrite proxy through.
|
|
return [
|
|
{
|
|
source: "/slack",
|
|
has: [{ type: "host", value: "ktx.sh" }],
|
|
destination:
|
|
"https://join.slack.com/t/ktxcommunity/shared_invite/zt-3y9b44m1x-LVyNNJD5nwaZHq4XS29LMQ",
|
|
permanent: false,
|
|
basePath: false,
|
|
},
|
|
{
|
|
source: "/:path*",
|
|
has: [{ type: "host", value: "docs.ktx.sh" }],
|
|
destination: "https://docs.kaelio.com/ktx/:path*",
|
|
permanent: true,
|
|
basePath: false,
|
|
},
|
|
{
|
|
source: "/:path((?!stars(?:/|$)).*)",
|
|
has: [{ type: "host", value: "ktx.sh" }],
|
|
destination: "https://docs.kaelio.com/ktx/:path",
|
|
permanent: true,
|
|
basePath: false,
|
|
},
|
|
{
|
|
source: "/",
|
|
destination: "/ktx/docs/getting-started/introduction",
|
|
permanent: false,
|
|
basePath: false,
|
|
},
|
|
{
|
|
source: "/docs",
|
|
destination: "/docs/getting-started/introduction",
|
|
permanent: false,
|
|
basePath: false,
|
|
},
|
|
];
|
|
},
|
|
};
|
|
|
|
export default withMDX(config);
|