Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Take A QuizChallenge yourself and boost your learning! Start the quiz now to earn credits.
Take A QuizUnlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
Take A QuizGeneral Tech Bugs & Fixes 3 years ago
User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.
You can't access api as public on different origin, port or protocol.The api you are accessing">accessing using having secure protocol, different origin 'expqnx.com' and you are accessing">accessing it on 'http://localhost:3000' using different protocol and origin so as per browser security rules policy you can't do so.
To resolve this issue
1)Go to the source where your api is running
2)open api code and
3)mention the following headers in your api:
if your api in node:
res.header ("Access-Control-Allow-origin", "*");
res.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept, Authorization"
The above i am giving the code snipped for api written in node.
You can set 'Access-Control-Allow-Origin' and 'Access-Control-Allow-Headers':'Origin' for your api written in any language.
No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.
Your experience on this site will be improved by allowing cookies. Read Cookie Policy
Your experience on this site will be improved by allowing cookies. Read Cookie Policy
manpreet
Best Answer
3 years ago
I am creating a PWA(Progressive Web Application) using https://forum.tuteehub.com/tag/react">react js.I am calling a login api from http://expgnx.com/api/v1 on http://localhost:3000.It is throwing the following error-
" No 'Access-Control-Allow-Origin' header is https://forum.tuteehub.com/tag/present">present on requested resource. Origin 'http://localhost:3000' is therefore not allowed access.".
Please help me out it stuck to me.