We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I am facing issue calling Remote API from localhost.
I am getting this error in browser console:
Reason: CORS request did not succeed
I am using nimble:restivus package
nimble:restivus
https://github.com/kahmali/meteor-restivus
As per documentation I am setting:
enableCors: true
in order to allow access from any origin. But no luck.
Here is my server side code:
myApi = new Restivus({ apiPath: 'api/', enableCors: true, useDefaultAuth: false, prettyJson: true, defaultOptionsEndpoint: { action: function() { this.response.writeHead(201, { "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Credentials": "true", "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept, Z-Key, Authorization", "Content-Type": "application/json", "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS" }); this.done(); return { status: "success", "data": { "message": "We love OPTIONS" } }; } } });
Here is my client side code:
$.ajax ({ type: "POST", url: "https://example.com/api/getUsers", dataType: 'json', headers: { "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI" } data: {}, success: function (){ alert('Thanks for your comment!'); } });
If I send nothing in header, the request succeed otherwise it gives error in browser console.
Can anyone help me with this?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I am facing issue calling Remote API from localhost.
I am getting this error in browser console:
Reason: CORS request did not succeed
I am using
nimble:restivus
packagehttps://github.com/kahmali/meteor-restivus
As per documentation I am setting:
enableCors: true
in order to allow access from any origin. But no luck.
Here is my server side code:
Here is my client side code:
If I send nothing in header, the request succeed otherwise it gives error in browser console.
Can anyone help me with this?
The text was updated successfully, but these errors were encountered: