How can I apply CORS in Apache Wink? What I basically need is adding an Access-Control-Allow-Origin: * header to every response send from Wink (where we will replace the * for the allowed origins).
How to handle CORS in Apache Wink?
957 Views Asked by Jos de Jong At
2
There are 2 best solutions below
0
Pritam Banerjee
On
Late answer, but can be useful for future readers. Use the following code when you send the response back:
Response
.status(200)
.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Headers", "origin, content-type, accept, authorization")
.header("Access-Control-Allow-Credentials", "true")
.header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, HEAD")
.header("Access-Control-Max-Age", "1209600")
.entity(yourJsonResponse)
.build();
Response is of type : javax.ws.rs.core.Response;
Related Questions in HTTP-HEADERS
- Disable Expect: 100 Continue in Play
- Data in mysql is set to 0 when send a POST using network tab, codeigniter
- Create HTTP GET Header Request
- write a parsed response from a json file in a div
- Adding HTTP Header to AJAX get request
- Play Framework: How to Add a Header to Every Response
- Can servers use http headers order to catch a browser signature?
- how use data like that to send request from windows phone
- CURL to POSTMAN
- How to get content from another website using JQ or JS
- Python, Flask: How to set response header for all responses
- Best practice for indicating a client side refresh/warning from server side
- Gather Client Domain from Rails API GET Request
- How to remove HTTP Server "Apache"?
- AngularJS header authorization format in Interceptor
Related Questions in RESPONSE
- What is an appropriate way to handle API loop with progress indicator?
- Paypal Delayed Chained Payments returns "Internal server error. Please check the server logs for details1"
- @JsonInclude(Include.NON_NULL) does not remove null fields from Inner POJO
- How to know when @ResponseBody ends
- Login in Extjs using java spring Bean
- ASP.NET Web API - Response with status code "Redirect (302)" doesn't work on Internet Explorer 10
- Remove boilerplate content from HTML page
- is there any way to allow/block remember password prompt of browser using c#/Java Script/Response headers.
- c# psexec response get params
- REST return Response.temporaryRedirect - Redirect was blocked for CORS request
- What does selectize expect as a return in order to load a select
- Multiple Json response to html Table format
- How to create a listener/Tracer for my web services
- How to display class as a JSON response in Java?
- netty: how to get complete message from client
Related Questions in CORS
- How do I find the fonts that are not loading in a CORS situation ( MoovWeb )?
- Angular/C# CORS Issue
- CORS in ionic app and django
- Enabling OPTIONS method on Azure Cloud Service (to enable CORS)
- "cross-origin requests that require preflight" - Cors apache configuration
- 405 Method Not Allowed - but Access-Control-Allow-Methods are set
- How to enable CORS between API and angular client
- CORS and CSRF(XSRF)
- Safari turns Simple Cors Request into Preflight after 302 redirect
- Enable CORS in OWIN Self Hosted WebApi
- Moving from development to production and FA icons are now squares
- XMLHttprequest not working the twitch.tv api
- Wso2ESB: Call Rest API through Entitlement policy from client producing CORS issue
- CORS - request made after preflight request expects 'Access-Control-Allow-Credentials' to be true
- CORS on Image Not Working
Related Questions in ACCESS-CONTROL
- Google Drive Sync + Read-only access
- Appying Denning security Model for django admin site
- NSTimer does not invoke a private func as selector
- How to block an action or controller without using AccessControl in Yii2?
- How do I check in PowerShell if a service has read access to a certain folder?
- Git for project with overlapping public and private portions
- XACML: How to control the access to the properties in a resource
- No 'Access-Control-Allow-Origin' header is present on the requested resource with API and website on same port
- REST API - How to restrict access to resources by role?
- Complex Authorization using XACML
- Twilio IP Address Control List for sending SMS/MMS messages
- Is it possible to edit the value of a public variable from another module?
- restrict viewing photos and article content on a wordpress site
- Roles missing in mongodb
- Access a control created at runtime (WPF)
Related Questions in APACHE-WINK
- Specify user handlers for JAX-RS when using annotation scanning
- Alternative to Apache Wink JSONObject/JSONException
- NullPointerException thrown by Apache Wink Accept in WAS Liberty 8.5.5.1
- Apache Wink connect to https resources
- Should I stick to axis2c or move to apache wink?
- Jersey or Wink on WebSphere
- Apache Wink Json REST Web Service
- Resource found but does not get executed
- Can Apache Wink be used for Android?
- JavaEE REST (Wink) - Can be REST Api class defines as singleton?
- Viewable in JAX-RS
- JAX-RS client/server application using JSON and Wink
- Index out of bounds exception when traversing InMultiPart object
- How to handle CORS in Apache Wink?
- JSON JAX-RS channel: Failed to find resource /HtmlDefaultRepresentation/defaultHtmlEntry.jsp
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
A possible solution can be returning a
javax.ws.rs.core.Responseobject. Using thejavax.ws.rs.core.Response.ResponseBuilderyou can add headers to the response.Update:
Another solution is to add a Servlet Filter (javax.servlet.Filter) on top of Wink that will add the headers to all responses.
Btw, in JAX-RS 2 it's possible to add Filters and Interceptors.