Skip to content

feat: Add option to allow http in serviceUrl, default false#460

Merged
esezen merged 2 commits into
Constructor-io:masterfrom
xkr47:feat/option-to-allow-http-in-serviceUrl
Jun 11, 2026
Merged

feat: Add option to allow http in serviceUrl, default false#460
esezen merged 2 commits into
Constructor-io:masterfrom
xkr47:feat/option-to-allow-http-in-serviceUrl

Conversation

@xkr47

@xkr47 xkr47 commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Would you approve adding an option to disable the "force https" feature from #309?

I have implemented a "fake Constructor" in our java backend so we can prototype changes to our catalog updates on our local machines without having to actually upload the catalog to a Constructor index. If not, we'll have keep using a fork of this repo, which would mean added maintenance work and delayed updates for the client library. Nevertheless it is net beneficial for us by letting us develop our Constructor experience in an agile manner.

Copilot AI review requested due to automatic review settings June 6, 2026 05:05
@xkr47 xkr47 requested a review from a team as a code owner June 6, 2026 05:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds an opt-in capability to allow http:// service URLs (instead of force-upgrading to HTTPS), primarily for local/dev environments, and updates types/tests accordingly.

Changes:

  • Extend addHTTPSToString to optionally keep http:// URLs when allowHttp is enabled.
  • Add allowHttpServiceUrl to client options typings and wire it through ConstructorIO initialization.
  • Update/add unit tests covering default vs allowHttp behavior.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/utils/helpers.js Adds allowHttp flag to preserve http:// URLs instead of upgrading to HTTPS.
src/types/index.d.ts Exposes allowHttpServiceUrl?: boolean in the public constructor options type.
src/constructorio.js Threads allowHttpServiceUrl into service URL normalization via addHTTPSToString.
spec/src/utils/helpers.js Expands tests for addHTTPSToString to cover the new flag.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/constructorio.js Outdated
* @param {object} parameters - Parameters for client instantiation
* @param {string} parameters.apiKey - Constructor.io API key
* @param {string} [parameters.serviceUrl='https://ac.cnstrc.com'] - API URL endpoint
* @param {string} [parameters.allowHttpServiceUrl=false] - Allow HTTP protocol in API URL endpoint

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Fixed

Comment thread spec/src/utils/helpers.js Outdated
expect(addHTTPSToString(testUrl)).to.equal(null);
});
});
describe('when allowHttp is not given', () => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Fixed

Comment thread src/utils/helpers.js
if (allowHttp) {
return url;
}
return url.replace('http', 'https');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not possible, since in this branch the http:// prefix is confirmed, so didn't change the code unnecessarily. I added tests though to verify this remains the case.

@xkr47 xkr47 force-pushed the feat/option-to-allow-http-in-serviceUrl branch from ad755d7 to 176bf87 Compare June 6, 2026 05:08
@xkr47 xkr47 force-pushed the feat/option-to-allow-http-in-serviceUrl branch from 176bf87 to c3aa875 Compare June 6, 2026 05:19

@esezen esezen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xkr47 thanks for your contribution. I will merge this in today

@esezen esezen merged commit 7430a25 into Constructor-io:master Jun 11, 2026
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants