Of course! I've also done this in my application. You can have as many paths in as many files as you want.
I assume, that you want to have the API routes in a different file than the Web routes.
In the RouteServiceProvider you can define which files, namespaces our middlewares or whatever you want to use.
Normally Laravel even comes with an api file in the folder routes. You can specify your JWT middleware to be on all api routes and keep your setup for the web routes like before.
Hey, sorry I forgot about that thing. But I think i know what your problem is. Maybe you have a case somewhere in your web routes where the route /{any} or something like that gets caught. There are two solutions:
Number one is that you exclude "api" via regex.
Number two is that you register api routes before web routes in your RouteServiceProvider.
Let me know if you used a solution of that or if you already got a different solution :)
After doing some research, I realized that I needed to use the api.php routes file versus the web.php routes file.
Then next challenge was validating user session because api doesn't use sessions and so I ended up using JWT.
Then next challenge after that was, how can I use the same set of Controllers for CRUD; without creating controllers for api versus web. The solution I used was in my BaseController, I inspected the route and set a variable $guard to either api or web. Then in my CRUD function I can validate auth by auth($this->guard)->check(). I can also have different return types based on the guard.
Everything is working for me, not sure if it the right or best approach but I couldn't find a better one.