DarkaOnLine / L5-Swagger

OpenApi or Swagger integration to Laravel
https://github.com/DarkaOnLine/L5-Swagger
MIT License
2.64k stars 394 forks source link

419 Page Expired (POST, PUT, PATCH, DELETE request) #611

Closed dimalebid closed 1 month ago

dimalebid commented 3 months ago

Problem:

when executing a POST, PUT, PATCH, DELETE request it gives the error "419 Page Expired", but GET works fine. I use a Sanctum user token for authorization

Sleepy4k commented 2 months ago

Hi dima, i met this error before, i going deep search and i solve it using response with accept content type to application/json, for now i dont have how to solve that issue with best practice but here my solved docs

      @OA\Response(response=200, description="Success",
          @OA\JsonContent(type="object",
              @OA\Property(property="sid", type="string", example="APxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"),
          )
      ),
      @OA\Response(response=401, description="Unauthorized",
          @OA\JsonContent(
              @OA\Property(property="message", type="string", example="Unauthenticated"),
          )
      ),
      @OA\Response(response=404, description="Not Found",
          @OA\JsonContent(
              @OA\Property(property="message", type="string", example="Resource not found"),
          )
      )

Make sure you added @OA\JsonContent, the concept is, when we sent request to server with content type application/json server will proccess it and return response to client with json response too as you added header accept: application/json.

Hope you solve that issue

Nowocyn commented 2 months ago

Do you have the same problem with curl or other tools to test your API calls? Which headers are been sent and which Laravel default middleware is active?

Sleepy4k commented 2 months ago

Do you have the same problem with curl or other tools to test your API calls? Which headers are been sent and which Laravel default middleware is active?

I think he doesn't reply anymore, anyway talking about the issue, as far as i know, we can solve it with adding web middleware on api section which located on l5-swagger config, and for me, i don't met that error again