totaljs / framework

Node.js framework
http://www.totaljs.com
Other
4.36k stars 450 forks source link

AJAX CORS cannot work with AWS Lambda #598

Closed rastislavcore closed 6 years ago

rastislavcore commented 6 years ago

I try GET data from AWS Lambda and following error appears:

Failed to load https://ojojoj.execute-api.eu-central-1.amazonaws.com/v1/sample/example/last: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://0.0.0.0:8000' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

Even CORS is setup on AWS.

I try: AJAXCACHE('!GET https://ojojoj.execute-api.eu-central-1.amazonaws.com/v1/sample/example/last', null, function(response) { ...

Javascript call work without any problems.

petersirka commented 6 years ago

Hi @raisty, just remove ! from URL in AJAXCACHE method. Let me know.

rastislavcore commented 6 years ago

Thank you for advice. I try it without ! also try put there some headers in {}. No success at all. Try function AJAX also. It surprising me that normal javascript works perfect.

Can we elaborate my problem? I will give you full specs.

petersirka commented 6 years ago

Of course. But headers must be allowed on server-side. Send me some example on my email, I'll test it.

rastislavcore commented 6 years ago

Sure Peter. I test our API as well and seems there is no problem on server. I will send you API test case and Javascript example, which work.

rastislavcore commented 6 years ago

After updating jComponent to latest version, works like charm. Thank you Peter!