Legacy Knowledge Base
Published Jun. 30, 2025

CORS request is failing

Written By

Pooja Bhambani

How To articles are not official guidelines or officially supporteddocumentation. They are community-contributed content and may not alwaysreflect the latest updates to Liferay DXP. We welcome your feedback toimprove How to articles!

While we make every effort to ensure this Knowledge Base is accurate, itmay not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with anyfeedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack"publication program, made available for informational purposes. Articlesin this program were published without a requirement for independentediting or verification and are provided "as is" withoutguarantee.

Before using any information from this article, independently verify itssuitability for your situation and project.

Issue

  • If the user allows any origin (Access-Control-Allow-Origin: *) to access the resource, the CORS request fails.
  • Steps to reproduce:
    1. Start Liferay DXP 7.4 U90
    2. Navigate to Control Panel > Instance Settings > Security Tools > CORS > Edit.
    3. Access-Control-Allow-Origin as *
    4. Now, call any OOTB get API, for this open postman tool > send this request (http://localhost:8080/o/headless-delivery/v1.0/sites/20119/blog-posting-images) > open code (right side) > copy javascript XHR code.
    5. Hit google.com > open console and paste the code.
    Expected Behavior: API Response must be seen as we allowed all origin to access the resource.
    Actual Behavior: Below error is appearing in the console:
    Access to XMLHttpRequest at 'http://localhost:8080/o/headless-delivery/v1.0/sites/20119/blog-posting-images' from origin 'https://www.google.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Environment

  • Liferay DXP 7.4

Resolution

  • There is an issue with the authorization header and the preflight. Hence, please add theAccess-Control-Allow-Headers: Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers, Authorizationin the CORS configuration.
  • And, make sure to add API endpoint in CORS configuration (for e.g. /o/headless-delivery/*)

Additional Information

Did this article resolve your issue ?

Legacy Knowledge Base