shadowwalker / next-pwa

Zero config PWA plugin for Next.js, with workbox 🧰
MIT License
3.89k stars 325 forks source link

Cannot loading icons, sw file in public folder on the production. #271

Closed hiepnh610 closed 3 years ago

hiepnh610 commented 3 years ago

Hi,

I was using Next PWA to generate my project. Everything work fine on the local.

But when I deploy my project to the production. I cannot get the things in public folder. Such as: favicon, icon and sw.js file.

This is my domain: https://parley-hub.com

When I open the devtool. I get some errrors like this.

Screen Shot 2021-08-24 at 12 11 32

My structure folder:

Screen Shot 2021-08-24 at 13 06 09

And my _app.tsx

import { ReactElement } from 'react';
import Head from 'next/head';
import type { AppProps } from 'next/app';

import '../styles/globals.css';

const MyApp = ({ Component, pageProps }: AppProps): ReactElement => {
  return (
    <>
      <Head>
        <meta charSet="utf-8" />
        <meta httpEquiv="X-UA-Compatible" content="IE=edge" />
        <meta
          name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"
        />
        <meta name="description" content="Description" />
        <meta name="keywords" content="Keywords" />
        <title>Welcome to Parley Hub</title>

        <link rel="manifest" href="/manifest.json" />
        <link
          href="/icon/favicon-16x16.png"
          rel="icon"
          type="image/png"
          sizes="16x16"
        />
        <link
          href="/icon/favicon-32x32.png"
          rel="icon"
          type="image/png"
          sizes="32x32"
        />
        <link rel="apple-touch-icon" href="/apple-icon.png"></link>
        <meta name="theme-color" content="#317EFB" />
      </Head>

      <Component {...pageProps} />
    </>
  );
};

export default MyApp;

next.config.js

/** @type {import('next').NextConfig} */

const withPWA = require('next-pwa');

module.exports = withPWA({
  reactStrictMode: true,
  pwa: {
    dest: 'public',
    register: true,
    skipWaiting: true
  }
});

Anyone has experience on this issue. Please help me.

Thanks to all of you!

shadowwalker commented 3 years ago

How did you deploy the service?

hiepnh610 commented 3 years ago

@shadowwalker I am using cloudflare to config my domain(DNS, HTTPS). The static file I push to GCR and using GKE to serve them.

hiepnh610 commented 3 years ago

@shadowwalker This was my mistake. I forgot copy the public folder in to the Dockerfile.