How to Set up CORS in Clarity
search cancel

How to Set up CORS in Clarity

book

Article ID: 236431

calendar_today

Updated On:

Products

Clarity PPM On Premise Clarity PPM SaaS

Issue/Introduction

An error is thrown in app-ca.log files

ERROR 2022-03-02 11:37:02,991 [https-jsse-nio2-8043-exec-31] security.CustomConfigCORSFilter (clarity:none:none:none) Failed to determine cors class java.lang.String cannot be cast to class java.util.List (java.lang.String and java.util.List are in module java.base of loader 'bootstrap')

OR 

ERROR 2022-02-17 12:43:36,633 [http-nio-maskedIP-80-exec-36] security.CustomConfigCORSFilter (clarity:none:none:none) Failed to determine cors null

OR you have a CORS warning in Dev Tools when accessing Clarity

Environment

Release : Any

Resolution

A value set for CORS_ALLOW_ORIGIN was incorrect. The values that are not seeded would need to be set up by the Clarity admin.

  1. To add values
    admin system-options -add CORS_ALLOW_ORIGIN http://abc.com -multi
  2. To display the current setup and compare to another environment: 
    admin  system-options -list  CORS_ALLOW_ORIGIN 
  3. To remove values:
    admin system-options -delete CORS_ALLOW_ORIGIN <domain name>
  4. After this, restart all services

Additional Information

How to ensure the values added are saved correctly in the database: 

Run the SQL queries to validate:

SELECT * FROM CMN_OPTION_VALUES where OPTION_ID IN (SELECT ID FROM cmn_options WHERE option_code='CORS_ALLOW_ORIGIN')

or

select v.id, v.value, o.option_code from cmn_option_values v, cmn_options o
where v.option_id = o.id and o.option_code like '%CORS%'