elbywan / wretch

A tiny wrapper built around fetch with an intuitive syntax. :candy:
MIT License
4.79k stars 96 forks source link

POST submits as OPTIONS #48

Closed selfagency closed 5 years ago

selfagency commented 5 years ago

This is my code:

        wretch(`${ENDPOINT}/people`)
          .post({
            person: {
              family_name: this.formData.lastName,
              given_name: this.formData.firstName,
              email_addresses: [
                {
                  address: this.formData.email
                }
              ]
            }
          })
          .res(res => {
              this.loading = false
              this.sucess = true
          })
          .catch(err => {
            this.loading = false
            this.error = err
          })

This is the network request that my browser submits:

Request URL:https://ENDPOINT/people
Request method:OPTIONS
Remote address:etc.:443
Status code: 200
Version:HTTP/2.0
Referrer Policy:no-referrer-when-downgrade

It also results in a CORS error, despite the server having its origin policy set to *:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://ENDPOINT/people. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

This request functions just fine in my REST client.

selfagency commented 5 years ago

never mind, i'm an idiot