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?
961 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
- Difficulty Accessing HTTP URLs/IP Addresses Due to Browser Redirecting to HTTPS: Seeking Solutions
- Put Request throwing 401 [no body] Unauthorized
- Postman HeaderList remote function not working
- HTTP/2 POST requests with compressed responses failing ERR_HTTP2_PROTOCOL_ERROR 200 (OK)
- axios post request keeps on pending in browser (works fine in postman)
- How to rewrite the name of a backend header with nginx as a forward or reverse proxy?
- Netfilter Module to Log HTTP Headers
- Download a file from pre-signed url from s3 using Angular
- HTTP 431 error on Azure App Service with AAD access for some users
- How do I format a date for an HTTP header in gleam?
- HTTP headers with two CSP
- X-Forwarded-For in the request-ip package potential bug
- Custom Header from Network Request not being retrieved with fetch API
- How are white-listed domains actually enforced by some of the big API providers?
- SOAP Client Python zeep Does not pass the specified headers parameters
Related Questions in RESPONSE
- Not getting Live data from Aviationstack api
- Parse the API response into desired type using axios or any other helpful methods in JavaScript/React.js
- rasa not responding when setting the value of session_persistence: true using socket
- i have intergrated daraja api with by booking app coded in java but in payments page it toasts an error message Error:Failed to initiate payment
- why does _doc appear after I use map in result mongoose
- Flask how can I use after_request to print out all responses and not break swagger-ui?
- response wrapper service layer vs controller
- Replacing google translate API with systran API
- Why response body not compressed when use webtestclient?
- ClassSerializer not working in NestJs with @Res decorator
- Encryption of Request and Decryption of Response
- HTTP server logging two times for a single request
- FastAPI - How to specify filename when downloading bytes content using Response class?
- Server sent events in pedestal returns empty response
- Do line breaks or spaces affect saml assertion validation?
Related Questions in CORS
- Composer installation fails and reverts ./composer.json and ./composer.lock to original content
- "(Reason: CORS header ‘Access-Control-Allow-Origin’ missing)" while trying to access Actix webserver from Wix site
- Why I am facing an Origin error despite having included the header in the code?
- Nextjs fetching data from child component
- Transitioning from Static to Dynamic Data in React with Express Backend
- CORS policy defined in next.config.js doesn't seem to be applied to API call
- CORS Err - Same origin is undefined in browser
- how to solve CORS problem whith local html three.js?
- XmlHttpRequest cannot load due to access control, but access is configured?
- problemas con los CORS en .net core 7 y angular 15
- Cross-Origin API calls with Laravel middleware
- Access control allow origin is undefined even though I am setting the header
- 400 Bad Request From React Axios Graphql SageX3
- CORS Error When Fetching File From Firebase Storage
- deploying a Node/React project in Vercel
Related Questions in ACCESS-CONTROL
- Access-Control-Allow-Origin alwasy set to * in spring boot
- Unable to View Roles in Storage Account in Azure getting Blank
- How can i fix CORS policy problem in Nuxt?
- How do I enable access control on an already up and running MongoDb container?
- Is there a universal way to test the Access Control List of a folder and its children in PowerShell, independently of inheritance?
- CORS error when deploying MERN app: 'Access-Control-Allow-Origin' missing header for hosted server, and 404 Not Found on server deployment
- How can i restrict access to an Azure app service?
- Use my login system to control access to Digital Ocean Spaces objects
- Nestjs access control cannot read roles
- Creating a Limited Privilege PostgreSQL Role for Backend Server
- Conditional Binding for Objects in Google Cloud Storage Buckets
- Cloud Run/Build artifacts buckets are created with Fine Grained access policy by default
- Memory Access Control in Windows Memory Management
- Azure DevOps - Decode ACE permission bits
- Netlify Deployment Access-Control-Allow-Origin
Related Questions in APACHE-WINK
- Index out of bounds exception when traversing InMultiPart object
- Set up a wink REST service and Client with custom provider
- Amdatu Web using Jersey
- Upload files to Websphere Liberty using JAX-RS 1.1 feature
- Export API from Apache Wink
- Can not use Wink 1.2.1 as JAX RS implementation in an Eclipse product
- unable to call REST 1.1 Service with Jaxrs-2.0 feature enabled
- Not able to fetch header data in rest assured for rest web service of type GET
- Secured REST call on Websphere
- URI Recognition in Java Using JAX-RS @Path Annotations at Class and Method Level
- IBM Process Server v8.5.5 throwing 415 Media not supported Error when calling a restful service
- Returning an excel document via a Java REST service with Apache Wink
- How to deal with urls having multiple @PathParam for RESTful calls in Moqui
- Not receiving body on Apache Wink Rest Client error with JAX-RS Application
- OSGi, Amdatu REST example doesn't work
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 # Hahtags
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.