4lejandrito / next-plausible

Simple integration for https://nextjs.org and https://plausible.io analytics
https://next-plausible.vercel.app
MIT License
603 stars 33 forks source link

script 404 with withPlausibleProxy #130

Open lucky13820 opened 1 month ago

lucky13820 commented 1 month ago
import "./src/env.mjs";
import { withSentryConfig } from "@sentry/nextjs";
import { withPlausibleProxy } from "next-plausible";
import withBundleAnalyzer from "@next/bundle-analyzer";

const bundleAnalyzer = withBundleAnalyzer({
  enabled: process.env.ANALYZE === "true",
});

/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    instrumentationHook: process.env.NODE_ENV === "production",
  },
  compress: true, // Enable gzip compression
};

// Apply bundleAnalyzer first
const configWithBundle = bundleAnalyzer(nextConfig);

// Then apply withPlausibleProxy to the bundled config
const configWithPlausible = withPlausibleProxy(configWithBundle);

// Finally, wrap withSentryConfig to include Sentry settings
export default withSentryConfig(configWithPlausible, {
  silent: !process.env.CI,
  telemetry: false,
  widenClientFileUpload: true,
  hideSourceMaps: true,
  disableLogger: true,
  tunnelRoute: "/monitoring",
});

With my current next config, when I visit http://localhost:3000/js/script.js, it would just show a 404 page. I tried to remove sentry config and only leave Plausible Proxy, still doesn't work, I couldn't figure out why that's the case.