Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Redirect on 404

Tomas Valenta8d1f38e815c1
diff --git a/apps/docs/next.config.mjs b/apps/docs/next.config.mjs
index 7dd9691b4..28e6f5a1b 100644
--- a/apps/docs/next.config.mjs
+++ b/apps/docs/next.config.mjs
@@ -33,7 +33,7 @@ function getFilesHash(rootPath) {
fsWalk.walkSync(rootPath, { stats: true }).forEach(e => {
if (!e.stats.isDirectory()) {
- if (e.path.includes(`/node_modules/`)) return // ignore node_modules which may contain symlinks
+ if (e.path.includes('/node_modules/')) return // ignore node_modules which may contain symlinks
const content = fs.readFileSync(e.path, 'utf8')
processFile(e.path, content)
}
@@ -54,13 +54,17 @@ const nextConfig = {
return config
},
async rewrites() {
- return [
- {
- source: '/ingest/:path*',
- destination: 'https://app.posthog.com/:path*',
- // BEWARE: setting basePath will break the analytics proxy
- },
- ]
+ return {
+ afterFiles: [
+ {
+ source: '/ingest/:path*',
+ destination: 'https://app.posthog.com/:path*',
+ // BEWARE: setting basePath will break the analytics proxy
+ },
+ { source: '/:path*', destination: '/_404/:path*' },
+ ]
+ }
+
},
async redirects() {
return [
diff --git a/apps/docs/src/app/not-found.tsx b/apps/docs/src/app/not-found.tsx
deleted file mode 100644
index af47511c7..000000000
--- a/apps/docs/src/app/not-found.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-// import { useRouter } from 'next/navigation'
-
-// export default function Page() {
-// redirect('/')
-// }
-
-
-
-import { Button } from '@/components/Button'
-import { HeroPattern } from '@/components/HeroPattern'
-
-export default function NotFound() {
- return (
- <>
- <HeroPattern />
- <div className="mx-auto flex h-full max-w-xl flex-col items-center justify-center py-16 text-center">
- <p className="text-sm font-semibold text-zinc-900 dark:text-white">404</p>
- <h1 className="mt-2 text-2xl font-bold text-zinc-900 dark:text-white">
- Page not found
- </h1>
- <p className="mt-2 text-base text-zinc-600 dark:text-zinc-400">
- Sorry, we couldn’t find the page you’re looking for.
- </p>
- <Button
- href="/"
- arrow="left"
- className="mt-8"
- >
- Back to docs
- </Button>
- </div>
- </>
- )
-}
diff --git a/apps/docs/src/pages/_404/[...path].tsx b/apps/docs/src/pages/_404/[...path].tsx
new file mode 100644
index 000000000..3be8c9c6f
--- /dev/null
+++ b/apps/docs/src/pages/_404/[...path].tsx
@@ -0,0 +1,15 @@
+import { GetServerSideProps } from 'next'
+
+// https://github.com/vercel/next.js/discussions/16749#discussioncomment-2992732
+export const getServerSideProps: GetServerSideProps = async () => {
+ return {
+ redirect: {
+ destination: '/',
+ permanent: false,
+ },
+ }
+}
+
+export default function Custom404() {
+ return null
+}