Not able to fetch data from stardog database using react app

Hi Stardog team,

I am trying to fetch data from Stardog database using React app. System have Kerberos authentication so I have left the username and password field empty. But the browser shows error in console:

Access to fetch at "{Stardog server url}" from origin localhost:3000 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. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Can you please provide the solution for this error ?

Are you passing the proper CORS info?

Does it work if you add

Header set Access-Control-Allow-Origin: *. #Useful for troubleshooting

to your request.

If it works great, but I would recommend that you read up on CORS and adjust the line above for your security need.

You can also limit who can connect using CORS Server Configuration | Stardog Documentation 7.6.4. By default all connection are accepted.

Hi Serge,
Where to add the line:
Header set Access-Control-Allow-Origin: *

Thanks,
Naman

Part of your HTTP header. Here a good resource for how to work with CORS Cross-Origin Resource Sharing (CORS) - HTTP | MDN

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.