1

I have built my Laravel+ReactJS project, JS is written in TypeScript(.tsx), and frontend is being rendered with Inertia.

Now I have run npm run build and copied all files to the shared hosting file manager, I used htaccess to modify the file base

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

RewriteBase /

RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]

Now the application(Laravel) starts, but ReactJS components are not rendered, it only shows the content of my "app.blade.php".

In the .env file, I have updated some variabales like:

APP_ENV=production
APP_KEY=base64:P2SZPbdUjDIhNOlt59QEKmKwHm25F0RQFec5RrF/O0Q=
APP_DEBUG=false
APP_URL=https://solstag.io
ASSET_URL=https://solstag.io/public

Please, what am I getting wrong, and what can I do?

3
  • Most shared hosting servers do not have /public has a doc root. I would suggest verifying how your server is setup. Also note that there is several tutorials out there for hosting a laravel site in shared hosting. I personally would not host in a shared environment that forces me to locate source files in the doc root. Not when you can deploy via Azure or Aws pretty reasonable until your traffic picks up. Commented Apr 16 at 1:08
  • Also, if public is your doc root your web path to it would not include the /public Commented Apr 16 at 1:11
  • 1
    "it only shows the content of my "app.blade.php"." - does it show the file in plain text, as in: you can see the PHP code? Commented Apr 16 at 5:58

1 Answer 1

0

Update the .env

ASSET_URL=https://solstag.io

Run npm run build verify you have access on browser https://solstag.io/js/app.js and https://solstag.io/css/app.css Update the .htaccess to:

<IfModule mod_rewrite.c>
    RewriteEngine On
    
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
    
    RewriteBase /
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

After that if you face any issue tell me what is that also see in conlose

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.