Files
firezone/website/next.config.mjs
Jamil 0e81ad11b2 fix(website): Fix script load errors and warnings (#5133)
A [Suspense boundary](https://react.dev/errors/419?invariant=419) error
from one of the tracking scripts is breaking any server-side rendering,
causing the entire website to switch to client rendering mode, which
means the full site bundle (multiple MB) needs to be downloaded before
first paint.

Unfortunately it doesn't happen in dev mode. This is a first attempt to
clean up some of the tracking vars to see if that fixes it.

refs firezone/gtm#268



# NOTE

You'll need to add `.env.local` in `website/` with these env vars since
this PR uses the `NEXT_PUBLIC_` env var naming scheme to make sure the
production ones are available in the production client bundle.

```
NEXT_PUBLIC_MIXPANEL_ID=313bdddc66b911f4afeb2c3242a78113
NEXT_PUBLIC_GOOGLE_ANALYTICS_ID=
NEXT_PUBLIC_LINKEDIN_PARTNER_ID=6200852
```
2024-05-26 22:31:56 +00:00

98 lines
2.4 KiB
JavaScript

// Adds GitHub-flavored markdown support to MDX
import nextMDX from "@next/mdx";
import remarkGfm from "remark-gfm";
import remarkParse from "remark-parse";
import rehypeStringify from "rehype-stringify";
import rehypeHighlight from "rehype-highlight";
import redirects from "./redirects.js";
// Add IDs to headings
import rehypeSlug from "rehype-slug";
// Add anchor links to headings with IDs
import rehypeAutolinkHeadings from "rehype-autolink-headings";
import { s } from "hastscript";
// Highlight.js languages
import langElixir from "highlight.js/lib/languages/elixir";
import langYaml from "highlight.js/lib/languages/yaml";
import langJson from "highlight.js/lib/languages/json";
import langBash from "highlight.js/lib/languages/bash";
import langRust from "highlight.js/lib/languages/rust";
import langRuby from "highlight.js/lib/languages/ruby";
import langPowerShell from "highlight.js/lib/languages/powershell";
const highlightLanguages = {
elixir: langElixir,
yaml: langYaml,
json: langJson,
bash: langBash,
rust: langRust,
ruby: langRuby,
powershell: langPowerShell,
};
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
typedRoutes: true,
},
async headers() {
return [
{
source: "/(.*)",
headers: [
{
key: "Permissions-Policy",
value: "browsing-topics=()",
},
],
},
];
},
async redirects() {
return redirects;
},
// Proxy GitHub requests to avoid CORS issues
async rewrites() {
return [
{
source: "/api/github/:path*",
destination: "https://github.com/:path*",
},
];
},
pageExtensions: ["js", "jsx", "md", "mdx", "ts", "tsx"],
images: {
dangerouslyAllowSVG: true,
remotePatterns: [
{ hostname: "runacap.com" },
{ hostname: "api.star-history.com" },
{ hostname: "github.com" },
{ hostname: "avatars.githubusercontent.com" },
{ hostname: "www.gravatar.com" },
],
},
};
const withMDX = nextMDX({
extension: /\.mdx?$/,
options: {
remarkPlugins: [remarkGfm, remarkParse],
rehypePlugins: [
rehypeSlug,
[rehypeAutolinkHeadings, { behavior: "wrap" }],
rehypeStringify,
[
rehypeHighlight,
{
ignoreMissing: true,
languages: highlightLanguages,
},
],
],
},
});
export default withMDX(nextConfig);