This usually occurs when the Laravel application tries to call itself but fails to establish a connection. There are several ways to solve this problem:
- try excluding /oauth/token from CSRF middleware
- Use the config function instead of env
- Change the url to localhost
- Use trim to remove unnecessary spaces and/or slashes
- Use url method
- Check with http prefix
- Try to call the route from an api client (postman, insomnia)
- Test on tinker