Skip to content

[Bug]: Force https for apollo client #1359

@marvincaspar

Description

@marvincaspar

Expected Behavior

The protocol which is used for the apollo client should be configurable and not forced to https.

I know you only should communicate with https for secure communication, but in our current environment we are hosting magento and vue storefront inside a k8s cluster. Communication from the internet is https, but communication within the cluster is http because we are already in a secure environment.

Actual Behavior

Apollo client is created with https agent

const { HttpsAgent } = AgentKeepAlive;
const agent = new HttpsAgent();

const httpLink = new HttpLink({
uri: settings.api,
// @ts-ignore
fetch: (url, options) => fetch(standardURL(url), options),
fetchOptions: {
agent,
},
...settings.customApolloHttpLinkOptions,
});

Possible Solution

Make the agent configurable or update the documentation how to change this to a http agent. I found a workaround/solution by overwriting the apollo config in the middleware.config.js file:

module.exports = {
  integrations: {
    magento: {
      configuration: {
        customApolloHttpLinkOptions: {
          useGETForQueries: true,
          fetchOptions: {},
        },
        ...
      },
      ...
    },
  },
};

Steps to reproduce

No response

What version of Magento 2 integration are you using?

1.0.2

What version of Node.js are you using?

16

What browser (and version) are you using?

What operating system (and version) are you using?

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage-neededIssues that need to be checked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions