I'm not sure my issue is to do with volumes. Tried without https still no change. I've listed some of my code below. Does anything look odd?
I've kept the image controller outside the Auth middleware while I'm trying to get this to work.
Local -
nginx | 2021/10/18 15:15:09 [warn] 3131: *2 a client request body is buffered to a temporary file /var/cache/nginx/client_temp/0000000001, client: 172.20.0.1, server: localhost, request: "POST /api/image HTTP/1.1", host: "127.0.0.1", referrer: "http://127.0.0.1/article/create"
nginx | 172.20.0.1 - - [18/Oct/2021:15:15:11 +0000] "POST /api/image HTTP/1.1" 200 35 "http://127.0.0.1/article/create" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36" "-"
php | 172.20.0.2 - 18/Oct/2021:15:15:09 +0000 "POST /index.php" 200
Production
nginx | 2021/10/18 15:20:48 [warn] 3131: *1 a client request body is buffered to a temporary file /var/cache/nginx/client_temp/0000000002, client: 86.3.140.138, server: pactest.tk, request: "POST /api/image HTTP/1.1", host: "pactest.tk", referrer: "https://pactest.tk/article/create"
nginx | 86.3.140.138 - - [18/Oct/2021:15:20:48 +0000] "POST /api/image HTTP/1.1" 500 11196 "https://pactest.tk/article/create" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36" "-"
php | 172.22.0.7 - 18/Oct/2021:15:20:48 +0000 "POST /index.php" 500
routes/api
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
Route::post('image', 'ImageController@store');
image controller
class ImageController extends Controller
{
public function store(Request $request)
{
if($request->file('file'))
{
$originalImage= $request->file('file');
$name = time().$originalImage->getClientOriginalName();
$img = ImageIntervention::make($originalImage);
$img->orientate();
$thumbnailPath = public_path().'/thumbnail/';
$originalPath = public_path().'/images/';
// var_dump($img);
$img->save($originalPath.$name);
$thumbnailImage = ImageIntervention::make($originalPath.$name)->fit(145, 145,null,'top');
$thumbnailImage->orientate();
$thumbnailImage->save($thumbnailPath.$name);
// var_dump($img);
// var_dump($thumbnailImage);
}
return response()->json($name, 200);
}
}