java ee - Jax-RS: CORS, OPTIONS requests and Authorization filter -


i've created api. it's running right , i've tested lot of times using curl, postman , other tools.

however, when call methods internet navigator (concretly firefox), it's making options requests instead of get, post , on...

why firefox making these sort of requests?

my problem on bearerfilter since it's checking requests have valid bearer token on authorization header:

@override public void filter(containerrequestcontext requestcontext) throws ioexception {     //check requests have valid authorized token. } 

so, options request has no authorization token on header. so, server rejects call.

any ideas how solve that?

by other hand, i've created corsfilter on server in order handle cors:

@provider public class corsfilter implements containerresponsefilter  {      @override     public void filter(containerrequestcontext requestcontext, containerresponsecontext responsecontext) throws ioexception {         responsecontext.getheaders().add("access-control-allow-origin", "*");         responsecontext.getheaders().add("access-control-allow-headers", "origin, content-type, accept, authorization");         responsecontext.getheaders().add("access-control-allow-credentials", "true");         responsecontext.getheaders().add("access-control-allow-methods", "get, post, put, delete, options, head");         responsecontext.getheaders().add("access-control-max-age", "1209600");     } } 


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -