Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run eloquent query from another local virtual host with curl or api #21533

Closed
mirbaagheri opened this issue Oct 4, 2017 · 3 comments
Closed

Comments

@mirbaagheri
Copy link

  • Laravel Version: 5.5
  • PHP Version: 7.1
  • Database Driver & Version:5.7.19

Description:

I have 2 virtual host in my wamp server under Windows 10(X64).

Virtual-host1 and Virtual-host2. virtual-host1 pointed to www/virtual1 and virtual-host2 pointed to www/virtual2

both virtual host running with Laravel 5.5.

Virtual-host1 have a configured database: virtualhost1_database Virtual-host2 does not have any database, default is: homestead

I defined a resource route in Virtual-host1: /users in the store function i use Eloquent and get user list from virtualhost1_database.

I try to get the list of users with Postman and it works fine: URL: virtual-host1/users Method: POST

Now I wanna send a Curl request from Virtual-host2 to Virtual-host1 to get the list of users.

curl_setopt_array($curl, array( CURLOPT_HEADER => true, CURLOPT_URL => 'http://virtual-host1/users\', CURLOPT_POST => 1, ));

But I have the following error: Access denied for user 'homestead'@'localhost' (using password: YES) (SQL: select * from users where active=1

That means virtual-host1 wanna get query from virtual-host2 database!

Can someone help me?

Steps To Reproduce:

@Dylan-DPC-zz
Copy link

I don't think this is a bug. You can seek help at the forums or the slack channel

@sisve
Copy link
Contributor

sisve commented Oct 5, 2017

Two sites on Apache on Windows requires cached configurations. It's a known but non-documented problem. Run php artisan config:cache on both sites.

#20207
#19990
#19454
#13906
#8191
vlucas/phpdotenv#219 (comment)


ONLY use env inside your config files, and then you MUST use the cache command to setup the config files. Then there are ZERO env issues in production.

vlucas/phpdotenv#76 (comment)

@mirbaagheri
Copy link
Author

Thank you @sisve
Solved 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants