Closed sofianegargouri closed 5 years ago
I tried it with jets-2.1.1
in chrome and it works fine for me.
HTML file I used for testing:
<html>
<script>
function httpGet(theUrl)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
xmlHttp.setRequestHeader("X-Amz-Date", "CORS");
xmlHttp.send( null );
return xmlHttp.responseText;
}
var res = httpGet("http://localhost:8888");
console.log(res);
</script>
</html>
Jets configuration:
Jets.application.configure do
config.cors = true
end
access-control-allow-headers: Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,X-Amz-User-Agent
@sofianegargouri can you please verify so that we can close the issue. Thanks 🙏
Closing until there are more details. Thanks!
Checklist
jets upgrade
command that makes this a simple task. There's also an Upgrading Guide: http://rubyonjets.com/docs/upgrading/My Environment
Expected Behaviour
OPTIONS requests are supposed to return a 200 HTTP Status with the
access-control-allow-origin
header setCurrent Behavior
Returns a 404 error
Step-by-step reproduction instructions
Just setup any route and call it from a JS script in a browser (Postman won't trigger the error)
Code Sample
When running an HTTP request to a Jets app from another app (with CORS), OPTIONS requests are not handled and always return a 404 error.
Solution Suggestion