QwikDev/partytown

[๐Ÿž]404 errror throws while implementing partytown in gatsby application

Closed this issue ยท 3 comments

Describe the bug

In order to improve the pagespeed of my website i have choose partytown to reduce the impact of third party code. so i have implemented partytown in gatsby site. i will share the code here
Here is partytown config in gatsby-ssr.js file

<Partytown
      key="partytown"
      resolveUrl={(url, location, type) => {
        let proxyUrl;
        if (type === 'script' && url.hostname.includes('cookiebot')) {
          proxyUrl = new URL('/api/partytown/proxy', 'http://localhost:9000/');
          proxyUrl.searchParams.append('url', url.href);
          return proxyUrl;
        }
        if (type === 'script' && url.hostname.includes('analytics')) {
          proxyUrl = new URL('/api/partytown/proxy', 'http://localhost:9000/');
          proxyUrl.searchParams.append('url', url.href);
          return proxyUrl;
        }
        return url;
      }}
      debug={true}
      forward={['dataLayer.push']}
    />,
    <script
      key="plugin-google-tagmanager"
      type="text/partytown"
      dangerouslySetInnerHTML={{
        __html: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
        new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
        j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
        'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
        })(window,document,'script','dataLayer','GTM-ID');`,
      }}
    />
   
  gatsby-node.js

    `exports.onPreBuild = async ({ actions: { createRedirect } }) => {
        await copyLibFiles(path.join(__dirname, "static", "~partytown"));
  createRedirect({
    fromPath: `/google-analytics?url=:url`,
    toPath: `:url`,
    statusCode: 200,
  });
  // This is only for GTM preview mode for debugging
  createRedirect({
    fromPath: `/googletagmanager/debug/bootstrap?url=:url`,
    toPath: `:url`,
    statusCode: 200,
  });
};
"@builder.io/partytown": "^0.9.2",
  "gatsby": "5.11.0"

I got 404 not found in network tab and as well as in inspect element of browser console

image image image image This is running in my localhost Please help me on this ?

Reproduction

None

Steps to reproduce

Mentioned above

Browser Info

Chrome

Additional Information

No response

Closing this ticket as i have fixed the issue

How did you fix it?

@gioboa still issue persist.. i have closed this ticket becoz i have mentioned same issue here #563