Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix setApiKey and setTwilioEmailAuth to prevent overwriting baseUrl #1386

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Be3751
Copy link

@Be3751 Be3751 commented Nov 6, 2023

Fixes

If you use setDefaultRequest to change baseUrl to a custom value, and execute setDefaultRequest before setApiKey, the baseUrl that you thought you had changed to a custom value will be overwritten with SENDGRID_BASE_URL.

For example, if you want to send a request to a mock SendGrid prepared in a local environment, you need to be careful about the execution order of setApiKey and setDefaultRequest as follows.

// You must execute setApiKey first.
const client = new Client();
client.setApiKey('SG.xxxxx');
client.setDefaultRequest('baseUrl', 'localhost:3030');

In order to resolve it, I've decided to make the following changes, including setTwilioEmailAuth, which has a similar dependency:

  • Do not execute setDefaultRequest('baseUrl', SENDGRID_BASE_URL) inside setApiKey since the default value for baseUrl is SENDGRID_BASE_URL .
  • Execute setDefaultRequest('baseUrl', TWILIO_BASE_URL) inside setTwilioEmailAuth depending on whether baseUrl has been updated to a custom value.

Checklist

  • I acknowledge that all my contributions will be made under the project's license
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the Contribution Guidelines and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

If you have questions, please file a support ticket.

@Be3751 Be3751 force-pushed the allow-custom-baseurl branch from 7e8231a to 6ec293b Compare November 29, 2023 15:37
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.

1 participant