mirror of
https://github.com/better-auth/better-hub
synced 2026-08-09 12:26:04 +00:00
141 lines
3.8 KiB
TypeScript
141 lines
3.8 KiB
TypeScript
import { withSentryConfig } from "@sentry/nextjs";
|
|
import type { NextConfig } from "next";
|
|
|
|
/**
|
|
* Known first-segment routes that should NOT be rewritten to /repos/...
|
|
* Includes all top-level app routes, API routes, and Next.js internals.
|
|
*/
|
|
const KNOWN_ROUTES = [
|
|
"api",
|
|
"dashboard",
|
|
"debug",
|
|
"extension",
|
|
"issues",
|
|
"theme-store",
|
|
"notifications",
|
|
"orgs",
|
|
"prompt",
|
|
"pulls",
|
|
"repos",
|
|
"search",
|
|
"stars",
|
|
"trending",
|
|
"users",
|
|
"_next",
|
|
"schemas",
|
|
];
|
|
|
|
const nextConfig: NextConfig = {
|
|
devIndicators: false,
|
|
serverExternalPackages: ["@prisma/client"],
|
|
experimental: {
|
|
staleTimes: {
|
|
dynamic: 300,
|
|
static: 180,
|
|
},
|
|
// serverComponentsHmrCache: true,
|
|
imgOptTimeoutInSeconds: 3,
|
|
},
|
|
logging: {
|
|
fetches: {
|
|
fullUrl: true,
|
|
},
|
|
},
|
|
// reactCompiler: true,
|
|
images: {
|
|
...(process.env.NODE_ENV === "development" && {
|
|
dangerouslyAllowLocalIP: true,
|
|
}),
|
|
remotePatterns: [
|
|
{ protocol: "https", hostname: "avatars.githubusercontent.com" },
|
|
{ protocol: "https", hostname: "*.githubusercontent.com" },
|
|
{ protocol: "https", hostname: "github.com" },
|
|
{ protocol: "https", hostname: "opengraph.githubassets.com" },
|
|
{ protocol: "https", hostname: "raw.githubusercontent.com" },
|
|
{ protocol: "https", hostname: "user-images.githubusercontent.com" },
|
|
{ protocol: "https", hostname: "repository-images.githubusercontent.com" },
|
|
{ protocol: "https", hostname: "better-hub.com" },
|
|
{ protocol: "https", hostname: "images.better-auth.com" },
|
|
],
|
|
},
|
|
async headers() {
|
|
return [
|
|
{
|
|
source: "/(.*)",
|
|
headers: [
|
|
{ key: "X-Content-Type-Options", value: "nosniff" },
|
|
{ key: "X-Frame-Options", value: "DENY" },
|
|
{
|
|
key: "Referrer-Policy",
|
|
value: "strict-origin-when-cross-origin",
|
|
},
|
|
{
|
|
key: "Permissions-Policy",
|
|
value: "camera=(), microphone=(), geolocation=()",
|
|
},
|
|
{
|
|
key: "Strict-Transport-Security",
|
|
value: "max-age=63072000; includeSubDomains; preload",
|
|
},
|
|
],
|
|
},
|
|
];
|
|
},
|
|
async rewrites() {
|
|
return {
|
|
beforeFiles: [
|
|
// Rewrite /:owner/:repo(/:path*) → /repos/:owner/:repo(/:path*)
|
|
// Only when the first segment is NOT a known app route.
|
|
// The negative lookahead excludes all known routes so only
|
|
// owner/repo patterns get rewritten.
|
|
{
|
|
source: `/:owner((?!${KNOWN_ROUTES.join("|")})\\w[\\w.\\-]*)/:repo/:path*`,
|
|
destination: "/repos/:owner/:repo/:path*",
|
|
},
|
|
{
|
|
source: `/:owner((?!${KNOWN_ROUTES.join("|")})\\w[\\w.\\-]*)/:repo`,
|
|
destination: "/repos/:owner/:repo",
|
|
},
|
|
],
|
|
};
|
|
},
|
|
};
|
|
|
|
export default withSentryConfig(nextConfig, {
|
|
// For all available options, see:
|
|
// https://www.npmjs.com/package/@sentry/webpack-plugin#options
|
|
|
|
org: "better-hub",
|
|
|
|
project: "javascript-nextjs",
|
|
|
|
// Only print logs for uploading source maps in CI
|
|
silent: !process.env.CI,
|
|
|
|
// For all available options, see:
|
|
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
|
|
|
|
// Upload a larger set of source maps for prettier stack traces (increases build time)
|
|
widenClientFileUpload: true,
|
|
|
|
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
|
|
// This can increase your server load as well as your hosting bill.
|
|
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
|
|
// side errors will fail.
|
|
tunnelRoute: "/monitoring",
|
|
|
|
webpack: {
|
|
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
|
|
// See the following for more information:
|
|
// https://docs.sentry.io/product/crons/
|
|
// https://vercel.com/docs/cron-jobs
|
|
automaticVercelMonitors: true,
|
|
|
|
// Tree-shaking options for reducing bundle size
|
|
treeshake: {
|
|
// Automatically tree-shake Sentry logger statements to reduce bundle size
|
|
removeDebugLogging: true,
|
|
},
|
|
},
|
|
});
|