Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Webservices CORS issue

Veerendra PatilJan 3 2020 — edited Jan 7 2020

Hi,

I think this questions is not fully related to this community---

We had an inhouse server.

APEX 5.1,

DB-11.

Apex hosted on a WLS along with Forms/Reports.

We have a hybrid mobile app built using ionic. It uses webservices created using APEX REST

Sample resource - https://server.com/ords/workspace/demows/employees/

Now we are moving the server to AWS with

APEX 19.1

DB 12c

Hosted using a Tomcat server.  Below is added on Tomcat server config

<filter>

    <filter-name>CorsFilter</filter-name>

    <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>

    <init-param>

        <param-name>allowedOrigins</param-name>

        <param-value>*</param-value>

    </init-param>

    <init-param>

        <param-name>allowedMethods</param-name>

        <param-value>*</param-value>

    </init-param>

    <init-param>

        <param-name>allowedHeaders</param-name>

        <param-value>*</param-value>

    </init-param>

</filter>

<filter-mapping>

    <filter-name>CorsFilter</filter-name>

    <url-pattern>/*</url-pattern>

</filter-mapping>

I have imported the webservices to new environment.

Sample resource now- http://server.com/ords/workspace/demows/employees/ --- It is not HTTPS

I get the below error when trying to access the webserices from mobile app

Access to XMLHttpRequest at 'http://server.com/ords/workspace/demows/employees/' from origin 'http://localhost:8100' 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.

  1. HttpErrorResponse {headers: HttpHeaders, status: 0, statusText: "Unknown Error", url: null, ok: false, …}
    1. headers: HttpHeaders
      1. normalizedNames: Map(0) {}
      2. lazyUpdate: null
      3. headers: Map(0) {}
      4. __proto__: Object
    2. status: 0
    3. statusText: "Unknown Error"
    4. url: null
    5. ok: false
    6. name: "HttpErrorResponse"
    7. message: "Http failure response for (unknown url): 0 Unknown Error"
    8. error: ProgressEvent {isTrusted: true, lengthComputable: false, loaded: 0, total: 0, type: "error", …}
    9. __proto__: HttpResponseBase

Can you please guide me how to resolve this issue?

Comments
Post Details
Added on Jan 3 2020
3 comments
542 views