Using the Postman Pro API, i have created a Postman mock for my collection.
I have created an example response for GET /auth/jwt/login
which returns an example JWT token.
I have used the mock successfully via postman (including the x-api-key
header) but when i try and use this in the browser, adding the header into my request (using axios), Postman responds to the preflight OPTIONS request with
{"error":{"name":"invalidCredentialsError","message":"Please provide the required `x-api-key` authentication header."}}
as expected the browser is stripping the x-api-key header (as per CORS spec) see: How do you send a custom header in a cross-domain (CORS) XMLHttpRequest?
So how do i use the Postman mock servers from my application while in development?