Hello, I am trying to launch Strapi Blog in Angular, I followed the tutorial carefully to create the backend as well as the frontend. But, when I launch my Angular project, It just shows the title ‘Strapi Blog’ but the page does not show any blog. I also check the graphql console and it works fine as it shows the published article. My Web Console shows this error:
“Cross-Origin Request Blocked: The Same Origin Policy disallows
reading the remote resource … Reason: CORS header
Any advice to solve this will be helpfull!
The Same Origin Policy (SOP) is a security measure standardized among browsers. It is needed to prevent Cross-Site Request Forgery (CSRF). The “Origin” mostly refers to a “Domain”. Same Origin Policy prevents different origins (domains) from interacting with each other, to prevent attacks such as CSRF (Cross Site Request Forgery) through such requests, like AJAX. In other words, the browser would not allow any site to make a request to any other site. Without Same Origin Policy , any web page would be able to access the DOM of other pages.
If you need to enable CORS on the server in case of localhost, you need to have the following on request header.
I have the same problem but a different issue. No articles are shown and my console gives the following errors:
:1337/graphql:1: Failed to load resource: the server responded with a status of 400 (Bad Request)
ERROR Error: Network error: Http failure response for http://localhost:1337/graphql: 400 Bad Request
at new ApolloError (bundle.esm.js:63:1)
at Set.forEach (<anonymous>)
at Map.forEach (<anonymous>)
at QueryManager.push../node_modules/apollo-client/bundle.esm.js.QueryManager.broadcastQueries (bundle.esm.js:1555:1)
at ZoneDelegate.invoke (zone-evergreen.js:359:1)
at Object.onInvoke (core.js:39699:1)
Any ideas? Something with Apollo and graphqp, but I have no idea…