spring-guides / getting-started-guides

Getting Started Guide template :: The template for new guides and also the place to request them.
https://github.com/spring-guides/getting-started-guides/wiki
Apache License 2.0
521 stars 204 forks source link

Getting Started Consuming REST AngularJS not pulling in data correctly #18

Closed ericop closed 8 years ago

ericop commented 8 years ago

So http://rest-service.guides.spring.io/greeting is up and running

{
   id: 415,
   content: "Hello, World!"
}

but runninggs-consuming-rest-angularjs-complete (obtained thru STS 3.7.1 File > New > Import Spring Getting Started Content) thru the app.groovy (with Spring CLI v1.2.7.RELEASE) doesn't pull in dynamic content to be rendered.

Expected when visiting http://localhost:8080/ The ID is 415

The content is Hello, World!

Actual

The ID is

The content is

dsyer commented 8 years ago

I don't know who is maintaining that service but it isn't serving CORS headers ( @gregturn maybe?). Look in your Javascupt console for errors like this:

XMLHttpRequest cannot load http://rest-service.guides.spring.io/greeting. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
ericop commented 8 years ago

Spot on @dsyer ! Hopefully the CORS stuff can get patched up and this demo will be operational once again.

robertolopezlopez commented 8 years ago

It's happening to me as well. On Firefox it's not logging anything, but on chromium I have got the following: XMLHttpRequest cannot load http://rest-service.guides.spring.io/greeting. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.

gregturn commented 8 years ago

All of the JS guides have this CORS issue. I haven't figured out how to get the policy Working properly for the CF-hosted backend service.

dsyer commented 8 years ago

Where is the source code?

robertolopezlopez commented 8 years ago

here https://github.com/spring-guides/gs-consuming-rest-angularjs/tree/master/complete @dsyer sorry, I misunderstood :-)

dsyer commented 8 years ago

Thanks but that's the guide, not the service it consumes.

dsyer commented 8 years ago

Works for me now (I think this is a duplicate of https://github.com/spring-guides/gs-consuming-rest-angularjs/issues/2)