在Heroku上使用Inerita和Laravel时出现路由错误

cmssoen2  于 2022-11-13  发布在  其他
关注(0)|答案(1)|浏览(99)

我的应用程序在本地环境中工作,但在Heroku上部署后,我收到以下错误

Uncaught (in promise) TypeError: Cannot read properties of null (reading 'dataset')

这就是屏幕上显示的内容

当我打开站点时
我试过将script标记从app.blade.php移到 *@ inerity * 标记之后,并将defer添加到脚本中,但是这些方法都不起作用。

<body class="font-sans antialiased">
    @inertia
    <script src="{{ mix('js/app.js') }}" defer></script>
    @env ('local')
        <script src="http://localhost:8080/js/bundle.js" defer></script>
    @endenv
</body>

我也试过跟随this article,但这也没有解决它。
我觉得我错过了什么,任何建议都将不胜感激!

kognpnkq

kognpnkq1#

stps to deoply laravel project on heroku server 

download cli 
https://devcenter.heroku.com/articles/heroku-cli#download-and-install

Prepare your Heroku CLI
Download and install Heroku installer base on your operating system.
heroku login

 Create Procfile inside your main Laravel project directory and push your project into Heroku and past the below code 
 web: vendor/bin/heroku-php-apache2 public/

run the following git commands 
git init
heroku create appname
git add .
git commit -m “Initial Commit”
git push heroku master
now try to open your laravel project you will find 500 error

Step 4 — Adding some configuration in Heroku base on .env file
read complete about them here 
https://devcenter.heroku.com/articles/config-vars
you can check the image as well
https://miro.medium.com/max/700/1*1uv-JEb3CNByEwC68vWGtg.png

Step 5 — Database configuration
First, click “Resources” menu, then in the “Add-ons” side, click “Find more add-ons”. You’ll redirect into Heroku Add-ons page.In the Heroku Add-ons page, we click Heroku Postgres. and install it its complete free .

then  set database properties 
check the link below 
https://miro.medium.com/max/700/1*9jLE08DL6gHyYTP89MuZtg.png
https://miro.medium.com/max/700/1*eMqch3Bz2J6BLGhZ6Himmw.png
https://miro.medium.com/max/700/1*u7gxP2fMnm3yScq1D0qlNQ.png

to update your project  
Ok, now we need to commit and push our config/database.php update into Heroku repository. Back into terminal and running this

git add .
git commit -m “Update database connection”
git push heroku master

Successful, now you are ready to running your Laravel App with Heroku. Hopefully this tutorial is useful and help you all guys :)

Thanks

相关问题