I have a Laravel Controller that returns an image when the user is logged in:
public function show($file)
{
$path = storage_path('app/files/' . basename($file));
if(!\Auth::check() || !\File::exists($path) return back();
return response()->file($path);
}
When I enter my-domain.com/show/image.png
in my browser, the image is shown when I am logged in.
When I am logged in and use a simple jQuery ajax call, it also works:
$.get('https://my-domain.com/show/image.png', '', function(data){
console.log('success');
console.log(data);
}
However, when I am logged it and use an ajax call through the DYMO JS Framework 3.0 (Docs) it suddenly does not work anymore.
To be more precise, when I call
dymo.label.framework.loadImageAsPngBase64('https://my-domain.com/show/image.png');
I get an error, that no image is returned. When I remove !\Auth::check()
in the controller, then it works.
Why is Auth
not working with a 3rd party library ajax call? Is there anything I can do to fix it?