title: React Builder tool won't set public url correctly
body: <p>I am trying to build my react app with react's build tool.</p>
  
  <pre><code>npm run build
  </code></pre>
  
  <p>But when I open the index.html file in the build folder, I can't see anything except a blank page. That's because react builder sets script and css paths wrong.</p>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"&gt;
  &lt;meta name="theme-color" content="#000000"&gt;
  &lt;link rel="manifest" href="/manifest.json"&gt;
  &lt;link rel="shortcut icon" href="/favicon.ico"&gt;
  &lt;title&gt;React App&lt;/title&gt;
  &lt;style&gt;
  &lt;/style&gt;
  &lt;link href="/static/css/main.5fa823c3.css" rel="stylesheet"&gt;
  &lt;/head&gt;
  &lt;body&gt;&lt;noscript&gt;You need to enable JavaScript to run this app.&lt;/noscript&gt;
  &lt;div id="root"&gt;&lt;/div&gt;
  &lt;script type="text/javascript" src="/static/js/main.09bdcb2b.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>As you can see, there is slash before every file path. If I fix this by hand, then the script works but the browser cannot find the "service-worker.js" file because value of the process.env.PUBLIC_URL is null. (service-worker.js exists in the right location)</p>
  
  <p><a href="https://i.stack.imgur.com/vyNv2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vyNv2.png" alt="enter image description here"></a></p>
  
  <pre><code>export default function register() {
    if (process.env.NODE_ENV === 'production' &amp;&amp; 'serviceWorker' in navigator) {
      window.addEventListener('load', () =&gt; {
        console.log("URL: "+process.env.PUBLIC_URL) //THIS IS NULL
        const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
        navigator.serviceWorker
          .register(swUrl)
          .then(registration =&gt; {
            registration.onupdatefound = () =&gt; {
              const installingWorker = registration.installing;
              installingWorker.onstatechange = () =&gt; {
                if (installingWorker.state === 'installed') {
                  if (navigator.serviceWorker.controller) {
                    // At this point, the old content will have been purged and
                    // the fresh content will have been added to the cache.
                    // It's the perfect time to display a "New content is
                    // available; please refresh." message in your web app.
                    console.log('New content is available; please refresh.');
                  } else {
                    // At this point, everything has been precached.
                    // It's the perfect time to display a
                    // "Content is cached for offline use." message.
                    console.log('Content is cached for offline use.');
                  }
                }
              };
            };
          })
          .catch(error =&gt; {
            console.error('Error during service worker registration:', error);
          });
      });
    }
  }
  
  export function unregister() {
    if ('serviceWorker' in navigator) {
      navigator.serviceWorker.ready.then(registration =&gt; {
        registration.unregister();
      });
    }
  }
  </code></pre>
  
  <p>Basically, it cannot set the public url.</p>
  
  <p>How can I fix this? There is almost no information about this problem anywhere.</p>