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

OPTIONS Calls #46

Open
upvince opened this issue May 18, 2018 · 4 comments
Open

OPTIONS Calls #46

upvince opened this issue May 18, 2018 · 4 comments

Comments

@upvince
Copy link

upvince commented May 18, 2018

I am doing http OPTIONS call to the mocked-api via a browser using axios. I created a OPTIONS.mock file which is in the same directory a my POST.mock (this is working), but unfortunately this does not match. Do you have any idea how I can solve this?

Reading from mocks/1.0/auth/OPTIONS.mock file: Not matched

@graciano
Copy link

Same here

@asgoth
Copy link

asgoth commented Sep 5, 2018

I didn't have any issues mocking an OPTIONS call. Just added a __/OPTIONS.mock in my mocks dir with

HTTP/1.1 200 OK
content-encoding: gzip
transfer-encoding: chunked
access-control-allow-origin: *
access-control-allow-credentials: true
strict-transport-security: max-age=31536000; includeSubDomains
access-control-max-age: 3600
access-control-allow-headers: expires,origin,language,pragma,accept,last-modified,x-xsrf-token,x-requested-with,content-type,location,cache-control,content-language
access-control-allow-methods: POST

Might be that you'll need to adapt access-control-allow-headers a bit.

The following POST (without generic wildcard) needs to have **access-control-allow-origin: ***.

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=utf-8

{
  "foo": "bar"
}

@asgoth asgoth mentioned this issue Sep 5, 2018
@Mishurin
Copy link

I didn't have any issues mocking an OPTIONS call. Just added a __/OPTIONS.mock in my mocks dir with

HTTP/1.1 200 OK
content-encoding: gzip
transfer-encoding: chunked
access-control-allow-origin: *
access-control-allow-credentials: true
strict-transport-security: max-age=31536000; includeSubDomains
access-control-max-age: 3600
access-control-allow-headers: expires,origin,language,pragma,accept,last-modified,x-xsrf-token,x-requested-with,content-type,location,cache-control,content-language
access-control-allow-methods: POST

Might be that you'll need to adapt access-control-allow-headers a bit.

The following POST (without generic wildcard) needs to have **access-control-allow-origin: ***.

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=utf-8

{
  "foo": "bar"
}

For me it worked only after adding the "access-control-allow-origin" in white list of the "access-control-allow-headers"

@graciano
Copy link

graciano commented Dec 4, 2019

Thanks @Mishurin it seems quite obvious to me now that I know how to solve this

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

No branches or pull requests

4 participants