1

I am new to angular, using v1.6, I have implemented a basic service for GET requests to communicate with Jetty service on a different host.

After annotating my service endpoints with CrossBorderResourceSharing. I am able to use $http without issues and I can seen the CORS flag in chrome debugger as well.

However $resource does not work gives the CORS error and does not show the CORS flag in debugger either , I am not using any custom settings for both just the basic call.

Let me know if sharing code snippet would help.

1 Answer 1

1

You need to enable CORS in the server endpoint. Add the following to your WEB-INF/web.xml

<filter-mapping>
<filter-name>cross-origin</filter-name>
<url-pattern>/*</url-pattern>

Sign up to request clarification or add additional context in comments.

3 Comments

I am using embedded Jetty, cxf, spring 4, I don't have a web.xml. Since $http is working, I am doubting if the issue is with UI
CORS issue is always related to server. I doubt that there should not be any such cases where CORS error appear for $resource and not for $http.
That's what is surprising me $http works perfectly, same service when called via $resource throws CORS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.