Skip to content
This repository was archived by the owner on Feb 20, 2026. It is now read-only.

fix: Allow user to set custom endpoints - #1101

Merged
danieljbruce merged 4 commits into
googleapis:mainfrom
danieljbruce:regional-endpoints
Apr 11, 2023
Merged

danieljbruce merged 4 commits into
googleapis:mainfrom
danieljbruce:regional-endpoints

Conversation

@danieljbruce

Copy link
Copy Markdown
Contributor

This change allows the user to set a custom endpoint when creating the client and it will work with the backend the way it is supposed to. It also ensures that we can still work with the emulator using the client.

With the code in its present state, this test should fail. A fix for regional endpoints intends to clean this up.
Only set the credentials to insecure if the custom endpoint is localhost and credentials are not provided. This way the user can set custom endpoints with the client and the request will work.
There is a test that uses a mock which is preventing the base url from being set. The test should be more realistic and when it is, the test passes with the new change.
@product-auto-label product-auto-label Bot added size: s Pull request size is small. api: datastore Issues related to the googleapis/nodejs-datastore API. labels Apr 6, 2023
@danieljbruce danieljbruce changed the title Allow user to set custom endpoints fix: Allow user to set custom endpoints Apr 6, 2023
Comment thread src/index.ts Outdated
const isUsingEmulator =
this.baseUrl_ &&
(this.baseUrl_.includes('localhost') ||
this.baseUrl_.includes('127.0.0.1'));

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.

Just in case, maybe add ::1 as an IPv6 version of localhost?

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.

Done

There is a third way the user can specify localhost. We should include this way as an option.
@danieljbruce danieljbruce added the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 11, 2023
@gcf-owl-bot gcf-owl-bot Bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 11, 2023
@danieljbruce
danieljbruce marked this pull request as ready for review April 11, 2023 14:45
@danieljbruce
danieljbruce requested review from a team April 11, 2023 14:45
@danieljbruce danieljbruce added the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 11, 2023
@gcf-owl-bot gcf-owl-bot Bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 11, 2023
@danieljbruce
danieljbruce merged commit e79fa49 into googleapis:main Apr 11, 2023
@edance

edance commented May 3, 2023

Copy link
Copy Markdown

hey all! This PR broke the docker setup for us. We're running the datastore emulator using a docker container so the datastore emulator host is something like datastore:8081. We want a connection that is both insecure and not to localhost.

How can we make changes to this code? If process.env.DATASTORE_EMULATOR_HOST is set, should we make isUsingEmulator == true

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: datastore Issues related to the googleapis/nodejs-datastore API. size: s Pull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

⌂ 换网址