![](/img/trans.png)
[英]Laravel 4 on production: 403 forbidden error on ajax call to update
[英]403 Forbidden Error for Videos on a production serve
我正在嘗試從我的 Laravel 應用程序的存儲中以 for 循環訪問視頻,但是,我收到 403 錯誤。 這只發生在我的生產站點上,我可以在本地加載它們,我在開發站點上對其進行了測試,它們加載正常。 我知道它們在服務器上,如果我在視頻中對它們進行硬編碼,它們就會很好地加載。 我在同一頁面上還有其他圖像可以從服務器加載得很好。 所以我有點不知道為什么他們不會加載或被禁止。 在我的 controller 我有這樣的:
public function showNewItem(Request $request, $id)
{
$products = Product::all();
$product = Product::findOrFail($id);
$prod_images = Product::find($id)->images;
$prod_videos = Product::find($id)->videos;
return view('pages.whats_new', compact('product', 'prod_images', 'prod_videos'))->withProducts($products);
}
在我看來,我有這個作為我的循環:
@foreach($prod_videos as $video)
<div class="video--container__item">
<video controls width="100%" height="auto" src=" /storage/product_video/{{ $video->video }}">
</video>
</div>
@endforeach
在頁面下方一點,我以完全相同的方式加載產品圖像,它們加載時沒有錯誤:
@foreach($prod_images as $image)
<div class="image grid-item">
<div class="img-wrapper">
<a href="{{ asset("storage/product_image/{$image->product_image}") }}">
<img src="{{ asset("storage/product_image/{$image->product_image}") }}" class="img-responsive">
</a>
<div class="img-overlay">
<h3 aria-hidden="true">
{{ $image->image_title }}
</h3>
<p aria-hidden="true">
{{ $image->caption }}
</p>
</div>
</div>
</div>
@endforeach
我以前從未遇到過這種情況。 是代碼中的東西嗎? 我想不明白。 我嘗試使用預先加載來重寫此代碼,但是每個產品頁面上的所有圖像都是相同的,並且視頻根本不會在本地、開發或生產中顯示。
會不會是 CORS 錯誤? 您應該查看控制台日志。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.