Reputation: 307
I know there's so many questions about this out there, but I can't seem to find the answer for my own.
I have a LoginController
with authenticate()
method which handle login process.
public function authenticate()
{
$email = $_POST['email'];
$password = $_POST['password'];
if (Auth::attempt(['email' => $email, 'password' => $password])) {
$http = new \GuzzleHttp\Client([
'base_uri' => 'http://myapp.test'
]);
$response = $http->post('oauth/token', [
'form_params' => [
'grant_type' => 'password',
'client_id' => '2',
'client_secret' => '_hashed-secret_',
'username' => $email,
'password' => $password,
'scope' => ''
]
]);
return json_decode((string) $response->getBody(), true);
}
}
I got cURL error 6: Could not resolve host: myapp.test (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
.I've rebooted my server, and nothing. I've rebuild all containers (currently using laradock
), and nothing.
The strange thing is, it only appears on the first attempt login. So, when the client attempt to login, there comes the error
, but when the client resend the form data (F5
), it disappears, and the client redirected to the homepage which indicates that the client is logged in.
I also reconfigured my .env
and other configurations that include hostname
(previously localhost
, changed to myapp.test
) but can't fix the error
.
Any kind of helps would be appreciated. Thanks in advance.
Upvotes: 2
Views: 5931
Reputation: 307
Ok, I already figured it out. Adding some configuration on docker-compose.yml
file.
### PHP-FPM Container #######################################
...
extra_hosts:
- "dockerhost:${DOCKER_HOST_IP}"
- "myapp.test:${DOCKER_HOST_IP}"
networks:
- frontend
- backend
- webserver_network
...
### NGINX Server Container ##################################
networks:
#- frontend
#- backend
webserver_network:
ipv4_address: ${WEBSERVER_IP}
frontend:
backend:
...
### Networks Setup ############################################
webserver_network:
driver: "bridge"
config:
- subnet: "${WEBSERVER_SUBNET}"
gateway: "${WEBSERVER_GATEWAY}"
Then, rebuild php-fpm
container. And got it works. Thanks.
Upvotes: 1