Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 11661

Laravel automatically redirects me to the default page

$
0
0

I declared a route using the apiResource method. If I type the command to list the routes, it is present in the list. However when I attack it with postman, I am directly redirected to the default Laravel page. However, if I integrate a dump into my method, and I repeat the action from postman, I enter my dump. What seems strange to me is at the end of the dump I have a line which tells me "redirection to the page" with a link back to the default page. How can I avoid this anomaly or is it a configuration problem?

I tried to use a classic Route:post, but I have the same problem, I cleared the cache, no improvement.

Do you have an explanation for this type of operation?

Here is an example of code which systematically sends me to the default Laravel page

 public function store(Request $request){    $data = $request->validate(["name" => "required|string","ctm" => "required|date","required" => "required|date","token" => "required|string","user" => "required|string",    ]);    $token = new ApiToken();    $token->fill($data);    try {        $token->save();    } catch(\Exception $e) {        return response()->json($e->getMessage(), 500);    }    return response()->json($token);}

Viewing all articles
Browse latest Browse all 11661

Trending Articles