reactjsweb-hosting

503 Error: Unexpected token '<' after deploying Create React App


I'm having a quite confusing problem: I built a React source that runs on local and Vercel very normally, integrated to run the Laravel API smoothly too. However, after uploaded the React build file to shared hosting, it has an Unexpected token "<" log error as shown below. I don't know if it's a 3rd party environment error or coming from mine? If there is any error from my client code or error in setting a start up file type to serve the backend, then how could my code run on both local and free hosting and also matched the API Laravel normally? Please help me figure this out, thank for reading. Cuz I'm pretty new to this so all your comments and answers will be appreciated.

I have tried to download the Laravel source code into my client and run it local to serve the React app after build also on my local and Vercel and it does work. And also, the API that running on hosting is still usable for the React source. The only problem is that when deployed the React App onto hosting -> error Server log on shared hosting


Solution

  • I also getting issue when i create a build and host on hosting server. So i create a new file .htaccess and paste the given code

    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteRule ^index\.html$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.html [L]
    <IfModule />
    

    Hope this works in your issue