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

Convert verb to uppercase #71

Merged
merged 2 commits into from
Apr 29, 2022
Merged

Conversation

sirlancelot
Copy link
Contributor

In Google Chrome, patch specifically seems to be causing problems. I'd been Googling for about an hour and finally came across this SO post: https://stackoverflow.com/a/67744766/51021

Apparently, some verbs (PATCH in my case) ARE case-sensitive when comparing against a pre-flight OPTIONS check.

I think in order to be the most compatible with the axios module, and to make PATCH work during cross-origin requests, these verbs should be made uppercase (See axios source: axios/lib/adapters/xhr.js#L32)

@googlebot
Copy link
Collaborator

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@sirlancelot
Copy link
Contributor Author

@googlebot I signed it!

@googlebot
Copy link
Collaborator

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

In Google Chrome, `patch` specifically seems to be causing problems. I'd been Googling for about an hour and finally came across this SO post: https://stackoverflow.com/a/67744766/51021

Apparently, some verbs (`PATCH` in my case) ARE case-sensitive when comparing against a pre-flight `OPTIONS` check.

I think in order to be the most compatible with the `axios` module, and to make `PATCH` work during cross-origin requests, these verbs should be made uppercase (See `axios` source: [axios/lib/adapters/xhr.js#L32](https://github.com/axios/axios/blob/5ad6994/lib/adapters/xhr.js#L32))
@sirlancelot
Copy link
Contributor Author

Fixed tests

@sirlancelot
Copy link
Contributor Author

A workaround I'm using for now until this PR is merged is that you can manually supply the verb using the full syntax:

import redaxios from "redaxios"
import { auth, baseURL } from "./helpers.js"

export async function patchItemById(itemId, payload) {
  const { data } = await redaxios(`/v1/item/${itemId}`, {
    data: payload,
    method: "PATCH", // <-- uppercase is required
    auth,
    baseURL,
  })
  return data
}

@AndreiEres
Copy link

Could someone approve it? =)

@developit developit linked an issue Apr 29, 2022 that may be closed by this pull request
@developit developit mentioned this pull request Apr 29, 2022
This was linked to issues Apr 29, 2022
@developit
Copy link
Owner

Size Change: +34 B (1%)

Total Size: 2.99 kB

Filename Size Change
dist/redaxios.js 982 B +10 B (1%)
dist/redaxios.module.js 983 B +12 B (1%)
dist/redaxios.umd.js 1.03 kB +12 B (1%)

@developit developit merged commit a3b7a14 into developit:master Apr 29, 2022
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.

Put request doesnt work Fetch blocked by CORS policy lower case method?
4 participants