Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

710
Visualizações
Deploy React in XAMPP

I'm new in React, and try to deploy app in my local machine using XAMPP. My problem is, when i tried to access the webpage, its gives 404 Not Found. When using npm start, its working properly.

enter image description here

I tried some advice from other similar question, but its still not working. This is my index.js

<React.StrictMode>
  <BrowserRouter basename='/react'>
    <Route exact path="/" component={Home} />
  </BrowserRouter>
</React.StrictMode>

And I put "homepage": "http://localhost/react/" in package.json

  "homepage": "http://localhost/react/",
  "name": "admin-dashboard-presensi",

After that, I run npm run build and move the folder to htdocs/react

enter image description here

This is what I put inside .htaccess:

Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Possible Error Sincaio:

1- You add url to package.json before you are build

2- missing to restart XAMPP server

3- make sure the folder build name is react, else rename directory or change base <BrowserRouter basename='/react'> and rebuild

4- also check the directory full path is correct, and its has permission which its allow you to visit it.

More Details: (Move the contents of the build folder into htdocs/react, not the build folder itself => Copied from @Phil)

If above points not work, you can check details bellow: I think you missing hosts and/or virtual host config:

<VirtualHost localhost:80>
    ServerName my-website.local
    ServerAlias www.my-website.local
    ServerAdmin webmaster@my-website.local
    DocumentRoot "path/to/your/build"
     <Directory path/to/your/build>
        Options Indexes FollowSymLinks MultiViews
  AllowOverride all
  Order Deny,Allow
        Allow from all
        Require all granted
    </Directory>
</VirtualHost> 

Also you need to add your new domain to hosts: vim /etc/hosts and add:

127.0.0.1 my-website.local

Another details may help you if its missing in your setup

Also, you need to make sure you are put .htaccess in public directory before build:

Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]

and then add: "homepage": "http://www.my-website.local", to package.json

Rebuild again, and restart XAMPP.

Note: I add alias domain nested of normal localhost, its better, but you can ignore that.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda