SWS-5007 / My-Experience

13 stars 0 forks source link

How to deploy the Laravel App as a static site to Netlify ? #4

Open SWS-5007 opened 1 year ago

SWS-5007 commented 1 year ago

Hi, I am going to deploy the Laravel Project on Netlify. For this, I referenced this guide, https://ryutahamasaki.com/posts/deploy-your-laravel-app-as-a-static-site-to-netlify/

SWS-5007 commented 1 year ago

And then, when I run this command $ php artisan vendor:publish --provider=Spatie\\Export\\ExportServiceProvider as guide above, that doesn't generate export.php file as Guide said. And I got this msg on cmd log:

No publishable resources for tag [].
Publishing complete.      

How can I solve this problem?

SWS-5007 commented 1 year ago

I found the solution like below. I run this command, php artisan vendor:publish. Then, inputted the Index Number as 11 like image below. image So export.php file has been generated successfully.

SWS-5007 commented 1 year ago

And I got many issues when I deploy on Netlify. I fixed all errors by adding this codebase below to netlify.toml.

[build]
  publish = "dist"

[[redirects]]
  from = "/*"
  to = "https://businesscard-frontend.netlify.app"
  status = 200
  force = "true"
  headers = {X-From = "Netlify"}

[[headers]]
  for = "/*"
  [headers.values]
    Access-Control-Allow-Origin = "https://businesscard-frontend.netlify.app"
    Access-Control-Allow-Credentials = "true"
    Access-Control-Allow-Methods = "GET, POST, PATCH, PUT, DELETE, OPTIONS"
    Access-Control-Allow-Headers = "Origin, Content-Type, X-Auth-Token, Authorization, X-Requested-With, x-xsrf-token"

So there is no error when I deploy.

SWS-5007 commented 1 year ago

But now, there is other issue. From Frontend Vue Project can't communicate with this Laravel Backend. There are 404errors. How can I solve this problem? Please let me know.