File size: 1,086 Bytes
5f32fbd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | <?php
declare(strict_types=1);
namespace App\Http\Controllers\Chatbot;
use App\Support\Chatbot\ChatbotHelper;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\File;
class ChatbotAssetsController
{
public function asset(Request $request, string $entryPoint)
{
$path = public_path($entryPoint);
$contentType = ChatbotHelper::getContentTypeFromEntryPoint($entryPoint);
if (File::exists($path)) {
$content = File::get($path);
return response($content, 200)->withHeaders([
'Content-Type' => $contentType,
// 'Cache-Control' => 'public, max-age=31536000',
'Vary' => 'Accept-Encoding',
'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Methods' => 'GET, HEAD, OPTIONS',
'Access-Control-Allow-Headers' => 'Accept, Origin, Content-Type, X-MagicAI-Chatbot, X-Livewire',
// 'Access-Control-Allow-Credentials' => 'false',
]);
}
abort(404);
}
}
|