0

I have an API endpoint on domain-1

Route::get('users', [UserApiController::class, 'index'])

and I try to retrieve the data from domain-2. I use the HTTP client to execute a request on the API route.

Http::get('http://www.domain-1/api/users')

But the request sends me back a Base table or view not found: 1146 the table 'domain-2-db.users' does not exists -> trying to find a table on the domain-2 database instead of performing the request on the domain-1-db

I tried hitting the API endpoint

http://www.domain-1/api/users 

directly in the browser or with Postman, and I can access the data. I also tried to submit a form from the domain-2, and I retrieve the data.

The error only occurs with the HTTP client.

May be that's pretty obvious, but I can't figure out what's the issue and how to fix it.

Any help appreciated!

4
  • What have you tried to resolve the problem? If such an error is thrown, that is usually not related to the usage of an API or the HttpClient - but related to the table not existing? Commented Sep 26, 2022 at 7:39
  • Hello, thanks for reply, i can perform a test with a form in a template from domain-2, and i can retrive the data, the error occurs only with an HTTP request. The table exist on the domain-1 project Commented Sep 26, 2022 at 7:41
  • Please add all clarification to your question by editing it. If you open http://www.domain-1/api/users in your browser, does this yield the same error? What did you try to check why this happens? Commented Sep 26, 2022 at 7:47
  • I have edited my post with the tests i did Commented Sep 26, 2022 at 7:59

1 Answer 1

0

Response came from this post https://stackoverflow.com/a/53803441/10309333

The solution was to change the DB_DATABASE const name from the env file

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.