Povilas Brilius
2 min readJan 17, 2021

--

Laravel Docker conversation violations — on compose instance, for example.

Two containers running on docker-compose.yml are negotiating for content on ports 2125 — frontend; and 2124 — backend. However, when pointing frontend form submission to backend /crawl

cd backend-alna
php artisan route:list
+--------+----------+----------+------+------------------------------+------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+----------+------+------------------------------+------------+
| | GET|HEAD | / | | Closure | web |
| | GET|HEAD | api/user | | Closure | api |
| | | | | | auth:api |
| | POST | crawl | | App\Http\Controllers\JobPost | web |
+--------+----------+----------+------+------------------------------+------------+

the response is negative in regard of content curl -LI -X OPTIONS localhost:2124/crawl

HTTP/1.1 200 OK
Date: Sun, 17 Jan 2021 09:23:05 GMT
Server: Apache
X-Powered-By: PHP/7.4.6
Allow: POST
Cache-Control: no-cache, private
Content-Length: 0
Content-Type: text/html; charset=UTF-8

Apparently, the mistake, erroneous behavior is that

Access to XMLHttpRequest at ‘http://localhost:2124/crawl' from origin ‘http://localhost:2125' has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

Laravel's docs, on their own, presume the CORS middleware is working by default on OPTIONS requests.

So you don’t need anything more nor else out of the box — just follow the guidelines, sending web form or CURL raw request on OPTIONS stage (see before) and the response should contain the appropriate CORS headers — though it’s missing, unfortunately. In this instance, the Laravel is not debugged correctly, an issue should be filed and it will be ultimately fixed.

So, today my plan is to file this complaint for not working Laravel case in the Broadway of a promising telemetry agency offering contract on a remote basis.

--

--

Povilas Brilius

PHP Developer in e-commerce and e-loans industry fields.