Skip to content

Commit

Permalink
Check if DATASTORE_EMULATOR_HOST is set
Browse files Browse the repository at this point in the history
Instead of checking to see if the endpoint is local, we should check to see if the datastore emulator variable is set. This is because there is an edge case where the user is using an emulator, but the emulator is not listening from local host and in this case we want to use insecure credentials.
  • Loading branch information
danieljbruce committed Sep 26, 2023
1 parent 11ffe3a commit dea1706
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,12 +505,7 @@ class Datastore extends DatastoreRequest {
},
options
);
const isUsingEmulator =
this.baseUrl_ &&
(this.baseUrl_.includes('localhost') ||
this.baseUrl_.includes('127.0.0.1') ||
this.baseUrl_.includes('::1'));
if (this.customEndpoint_ && isUsingEmulator) {
if (this.customEndpoint_ && process.env.DATASTORE_EMULATOR_HOST) {
this.options.sslCreds ??= grpc.credentials.createInsecure();
}

Expand Down

0 comments on commit dea1706

Please sign in to comment.