Protected Routes

To protect routes, keep the routes inside if statement as below

if($auth->routes()){

  // Protect routes must be in this if statment
  
  $router->get("/protected-route",function(){
     echo "You've just accessed the protected route";
  })

}

Access Protected Route with Token

HEAD -/protected-route

Headers

NameTypeDescription

Authorization

string

Bearer Token

{
  "status":200,
  "message:"Succefully retrieved data",
  "data":[..]
}

You must have token to access protected routes.

To generate a token, see under Authentication section.

Last updated