I have a set of directories in my Laravel storage directory.
path is \storage\app\public\docs
.
Inside the docs
directory there are a set of folders that contain HTML,CSS,JS.
I want to access those folders/files if users is logedin. here is my route:
Route::get('storage/{directory}/{subdirectory}/{page}', function ($directory,$subdirectory,$page)
{
if(!Auth::check()){
die('Unauth access');
}
$path = storage_path('app/public/' . $directory.'/'.$subdirectory.'/'.$page);
if (!File::exists($path)) {
abort(404);
}
$file = File::get($path);
$type = File::mimeType($path);
$response = Response::make($file, 200);
$response->header("Content-Type", $type);
return $response;
});
example:
url:
http://localhost:8000/storage/docs/62199911-74c61aaf688c0d374f23253218a12a9b81eaba4c/index.html
The response is loading success. but there are some external css and js are caled in the index.html. But they are not load in the response.
The js and css are include in css and js directory that contain in 62199911-74c61aaf688c0d374f23253218a12a9b81eaba4c
directory
Is there a way to allow assess each files and folder in storage directory when user is logedin(not for guess users).