我正在使用 Laravel 5.8 版本開發(fā) API 應(yīng)用程序。當(dāng)向productsapi 端點(diǎn)發(fā)出 get 請求時(shí),我返回一個(gè)如下所示的ProductResource集合public function toArray($request){ return [ 'id' => $this->id, 'name' => $this->name, 'category' => $this->category, 'description' => $this->description, 'status' => $this->status, 'price' => $this->price, 'barrels' => $this->barrels, 'interest' => $this->interest, 'start' => $this->start, 'end' => $this->end, 'hidden' => $this->hidden, 'imageUrl' => asset('storage/images/products/' . $this->image->name) ];}我面臨的挑戰(zhàn)是,在我的本地服務(wù)器上單擊返回imageUrl的圖像顯示正確的圖像,但在登臺環(huán)境中,我得到了默認(rèn)的404未找到頁面。我在我正在開發(fā)的本地服務(wù)器上創(chuàng)建了一個(gè)符號鏈接,public/storage用于storage/app/public在將應(yīng)用程序文件上傳到登臺環(huán)境之前存儲實(shí)際的圖像文件??焖贆z查storage/app/public/images/products臨時(shí)環(huán)境中的 會顯示圖像文件,但我仍然無法從瀏覽器中查看它。這種行為的可能原因是什么?這是我的本地和登臺環(huán)境中的資源示例本地/開發(fā)服務(wù)器{ "id": 17, "name": "test", "category": "test", "description": "test", "status": "test", "price": 10990, "barrels": 207736, "interest": 0.2, "start": "2019-07-25", "end": "2019-08-25", "hidden": 0, "imageUrl": "http://localhost:8000/storage/images/products/pramopro_test_17.jpeg" }登臺服務(wù)器{ "id": 13, "name": "test prod", "category": "test prod category", "description": "test prod description", "status": "loading", "price": 10000, "barrels": 300000, "interest": 0.2, "start": "2019-07-22", "end": "2019-08-28", "hidden": 0, "imageUrl": "http://staging.pramopro.com/storage/images/products/pramopro_testprod_13.jpeg" }
圖像 url 在開發(fā)服務(wù)器上工作,但在生產(chǎn)服務(wù)器上失敗
慕無忌1623718
2021-10-22 13:40:12