14 years ago
Mock Service: Cross-domain from JavaScript
I'm trying to use my Mock Service from JavaScript, however, in order for the browser to allow me to send cross-domain requests, i have to receive one http-message containing these three headers:
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 3628800
Access-Control-Allow-Methods: POST
I know how to change the headers in the Mock Responses, but in order to get a mock response, you have to be able to send a valid requests, which is not possible before you've received the three headers above. So you see it's kind of a chicken and the egg problem.
I'm able to just send GET requests or empty POST requests or OPTIONS request, but then the mock service just returns an error.
Is it possible to change the headers on the errors? That way i could first send an invalid request, then receive the needed security info, and then send a valid request.
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 3628800
Access-Control-Allow-Methods: POST
I know how to change the headers in the Mock Responses, but in order to get a mock response, you have to be able to send a valid requests, which is not possible before you've received the three headers above. So you see it's kind of a chicken and the egg problem.
I'm able to just send GET requests or empty POST requests or OPTIONS request, but then the mock service just returns an error.
Is it possible to change the headers on the errors? That way i could first send an invalid request, then receive the needed security info, and then send a valid request.