Get eloquent query from another local virtual host

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 16:56:47

问题


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 call an 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?


回答1:


Two sites on Apache on Windows requires cached configurations. More detail and Solution here: https://github.com/laravel/framework/issues/21533#issuecomment-334352170



来源:https://stackoverflow.com/questions/46543312/get-eloquent-query-from-another-local-virtual-host

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!