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 User-Agent request header #40

Merged
merged 1 commit into from
Jun 26, 2018
Merged

Fix User-Agent request header #40

merged 1 commit into from
Jun 26, 2018

Conversation

wKovacs64
Copy link
Owner

Fixes broken implementation from #39.

I thought the previous implementation would cause the undefined
User-Agent to be omitted from the request headers, but it was
actually being included (triggering CORS). I'm dumb. Added a test to
prevent this in the future.
@wKovacs64 wKovacs64 merged commit bd2e320 into develop Jun 26, 2018
@wKovacs64 wKovacs64 deleted the fix-ua branch June 26, 2018 21:53
@wKovacs64
Copy link
Owner Author

See also: #38

@@ -14,6 +10,9 @@ export default Axios.create({
baseURL: 'https://haveibeenpwned.com/api',
headers: {
Accept: 'application/vnd.haveibeenpwned.v2+json',
'User-Agent': customUserAgent,
// Add a custom User-Agent header when running outside the browser
...(typeof navigator === 'undefined' && {
Copy link

Choose a reason for hiding this comment

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

You taught me something: optional spreading!

Copy link
Owner Author

Choose a reason for hiding this comment

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

Sweet! 😄

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.

2 participants