What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hi herd… I’m trying to access the Glue Api from a parallel PHP application running in a separate Do

U02P7B6K2LC
U02P7B6K2LC Posts: 121 🧑🏻‍🚀 - Cadet
edited October 2022 in Help

Hi herd…

I’m trying to access the Glue Api from a parallel PHP application running in a separate Docker instance, but it looks like Glue won’t accept the connection. I’m using Symfony’s HttpClient:

Fatal error: Uncaught Symfony\Component\HttpClient\Exception\ClientException: HTTP/1.1 404 Not Found returned for "<http://glue.pricecoshop.local/catalog-search?q=Cabbage>". in /var/www/html/vendor/symfony/http-client/Response/CommonResponseTrait.php:174 Stack trace: #0 /var/www/html/vendor/symfony/http-client/Response/CommonResponseTrait.php(48): Symfony\Component\HttpClient\Response\CurlResponse->checkStatusCode() #1 /var/www/html/vendor/symfony/http-client/Response/CurlResponse.php(247): Symfony\Component\HttpClient\Response\CurlResponse->doGetContent(true) #2 /var/www/html/vendor/symfony/http-client/Response/CommonResponseTrait.php(83): Symfony\Component\HttpClient\Response\CurlResponse->getContent(true) ...

When I access the same endpoint via Postman it works fine.
When I simply type the endpoint URL into the browser, it works fine.
Also when I run the PHP script from the CLI it works too…

But it errors only when I try to access via the docker PHP application.
I’ve tried doing a simple CURL request from the application and this doesn’t work either.

My Spryker config is:

$config[GlueApplicationConstants::GLUE_APPLICATION_CORS_ALLOW_ORIGIN] = '*';

so it’s not a CORS thing…

Any help would be much appreciated! :)

Comments

  • Alberto Reyer
    Alberto Reyer Posts: 690 🪐 - Explorer

    I would check if the accept header is the same as in Postman. Postman adds the basic headers, like accept with * if they are not present.

    If you do an GET request try if it works in the browser, if so missing accept header is very likely your problem.

  • U02P7B6K2LC
    U02P7B6K2LC Posts: 121 🧑🏻‍🚀 - Cadet

    I think you’re right but I’m playing around with headers and getting 404's every time.

  • U02P7B6K2LC
    U02P7B6K2LC Posts: 121 🧑🏻‍🚀 - Cadet

    I’ll keep trying! 🙂

  • U02P7B6K2LC
    U02P7B6K2LC Posts: 121 🧑🏻‍🚀 - Cadet

    Oh no…! 🙀

    I just realised…! I’m trying to access localhost on a different machine (technically) … since the 2 docker containers are separate!!!

    I can’t believe i missed that!!!