Git Product home page Git Product logo

Comments (6)

Kmaschta avatar Kmaschta commented on April 26, 2024

Your API server needs to manage CORS by exposing Access-Control-Allow-Origin HTTP Header on each response.

Here is an explainer/tutorial.

from react-admin.

gelopfalcon avatar gelopfalcon commented on April 26, 2024

Great. Thanks. The problem is not the admin component?
Do you believe that the problem is my server api?

El 4 nov. 2016 7:25 a. m., "Kmaschta" [email protected] escribió:

Your API servers need to manage CORS by exposing
Access-Control-Allow-Origin HTTP Header on each response.

Here is an explainer/tutorial
https://www.eriwen.com/javascript/how-to-cors/.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/marmelab/admin-on-rest/issues/126#issuecomment-258429849,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AD7W_5_CssfAD-RMQU2Bw39rpvfcdiqhks5q6zItgaJpZM4Kpe6l
.

from react-admin.

Kmaschta avatar Kmaschta commented on April 26, 2024

Sure, it is.
All the modern browsers doesn't allow to do HTTP requests other than GET if the client host is different from the requested server.

It is the server's role to define which host is allowed to request it.

from react-admin.

gelopfalcon avatar gelopfalcon commented on April 26, 2024

Thanks for the support. Right now I am reviewing my API server.
For the moment, I attached the error console browser.

2016-11-04 7:35 GMT-06:00 Kmaschta [email protected]:

Sure, it is.
All the moderns browsers doesn't allow to do HTTP requests other than GET
if the client host is different from the requested server.

It is the serve's role to define which host is allowed to request it.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/marmelab/admin-on-rest/issues/126#issuecomment-258432191,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AD7W_6OBzDtYw5oKl3vb8gs7h6rO2uR4ks5q6zSLgaJpZM4Kpe6l
.

"El secreto del éxito no lo conozco, pero el del fracaso es tratar de
agradarle a los demas"

from react-admin.

gelopfalcon avatar gelopfalcon commented on April 26, 2024

The problem persist. I added the server API

// CORS (Cross-Origin Resource Sharing) headers to support Cross-site

HTTP requests
app.all('', (req, res, next) => {
res.header("Access-Control-Allow-Origin", "
");
res.header("Access-Control-Allow-Methods",
"GET,HEAD,OPTIONS,POST,PUT");
res.header("Access-Control-Allow-Headers", "Origin,
X-Requested-With, Content-Type, Accept, Authorization");
next();

});

In the admin I have:

<Admin restClient={simpleRestClient('http://localhost:5000')}
title="Example Admin">

,
document.getElementById('root')
);

Error console

fetch-mock.js:284 unmatched call to http://localhost:5000/todos
Fetch API cannot load http://localhost:5000/todos. Response to preflight
request doesn't pass access control check: A wildcard '*' cannot be used in
the 'Access-Control-Allow-Origin' header when the credentials flag is true.
Origin 'http://localhost:8080' is therefore not allowed access.
failure.js:18 TypeError: Failed to fetch

2016-11-04 8:19 GMT-06:00 Gerardo Lopez [email protected]:

Thanks for the support. Right now I am reviewing my API server.
For the moment, I attached the error console browser.

2016-11-04 7:35 GMT-06:00 Kmaschta [email protected]:

Sure, it is.
All the moderns browsers doesn't allow to do HTTP requests other than GET
if the client host is different from the requested server.

It is the serve's role to define which host is allowed to request it.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/marmelab/admin-on-rest/issues/126#issuecomment-258432191,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AD7W_6OBzDtYw5oKl3vb8gs7h6rO2uR4ks5q6zSLgaJpZM4Kpe6l
.

"El secreto del éxito no lo conozco, pero el del fracaso es tratar de
agradarle a los demas"

"El secreto del éxito no lo conozco, pero el del fracaso es tratar de
agradarle a los demas"

from react-admin.

fzaninotto avatar fzaninotto commented on April 26, 2024

The error message seems pretty self explanatory. Try to restrict the Access-Control-Allow-Origin header to the actual locations you're issuing the request from.

Note that if both the admin and the API are hosted on localhost, you shouldn't have any CORS problem.

from react-admin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.