403 Forbidden Error for Videos on a production serve

问题描述

我正在尝试从我的 Laravel 应用程序的存储中访问 for 循环中的视频,但是,我收到了 403 错误。这仅发生在我的生产站点上,我可以在本地加载它们,并在开发站点上对其进行测试,它们加载良好。我知道它们在服务器上,如果我在视频中硬编码它们会加载得很好。我在同一页面上还有其他图像,它们从服务器加载得很好。所以我有点不知道为什么他们不会加载或被禁止。在我的控制器中,我是这样的:

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

我以前从未遇到过这种情况。它是代码中的东西吗?我想不明白。我曾尝试使用预先加载重写此代码,但随后每个产品页面上的所有图像都是相同的,并且视频在本地、开发或生产中根本不显示

这是我看到的错误的屏幕截图:

enter image description here

解决方法

会不会是 CORS 错误?您应该查看控制台日志。