'This localhost page can’t be found

I just configure vitejs in my pre-build react application, but when starting the app it starts it on terminal but on browser, I find this "This localhost page can’t be found" here is my vite.config.js

import { defineConfig } from 'vite';
import reactRefresh from '@vitejs/plugin-react-refresh';
import svgr from 'vite-plugin-svgr';

export default defineConfig(() => {
  const config = {
    build: {
      outDir: 'build',
    },
    plugins: [reactRefresh(), svgr()],
    define: {
      'process.env.RUN_ENV': JSON.stringify(''),
    },
    resolve: {
      alias: [{ find: /^~/, replacement: '' }],
    },
    css: {
      preprocessorOptions: {
        less: {
          javascriptEnabled: true,
          modifyVars: { '@icon-font-path': './fonts' }, // copied the files from node_modules/rsuite/es/styles/fonts to get around build issues
        },
      },
    },
    server: {
      https: {
        maxSessionMemory: 100
      }
    }
  };
  return config;
});

here is my index.html

    <!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <meta name="theme-color" content="#000000" />
  <title>abc</title>
  <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Lato" />
  <link rel="stylesheet" type="text/css" href="/assets/styles/global.css" />
  <link rel="manifest" href="/manifest.json" />
  <script>var global = window</script> 
  <script src="/config.js"></script>
</head>

<body>
  <noscript>You need to enable JavaScript to run this app.</noscript>
  <div id="root"></div>
  <script type="module" src="/src/index.tsx"></script>
</body>

</html>

and here is my code structure. enter image description here



Solution 1:[1]

Make sure you are using the correct port with localhost. Try 3000, 8080 or 8000 if you haven't already or else try 127.0.0.1

Solution 2:[2]

You must check your project config as the 404 error generally happen when vite doesn't find the entrypoint index.html

Edit

looking at your vite.config.js you should access your app from https://localhost:3000. If you want to run the app on standard http port 80, replace the config https to http.

server: {
  https: { // https => https://localhost:3000 | http => http://localhost:3000
    maxSessionMemory: 100
  }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 lakimapturn
Solution 2