kerkkoh / simple-clothing-store

Simple clothing store for on-demand printing from Printful, payments from Paypal, implemented with Node.js & React.
MIT License
69 stars 23 forks source link

CORS #5

Closed nickonometry closed 3 years ago

nickonometry commented 3 years ago

Just wanted to say thank you for putting this example store up using the printful API, it's basically the only example I could find online. I am trying to setup a similar store in nuxtJS, using axios for my API calls, but I cannot access any API data from Printful due to CORS policy. How did you get around this? I can access my data no problem via Postman. Sorry for using github issues as a way to communicate, I couldn't find an email address or anything lol

kerkkoh commented 3 years ago

I'm assuming you are attempting to make the API requests directly from the browser, which is your issue. There are some methods for getting around CORS itself, but the reasonable method is to pass traffic between the API and your application through a backend application (in this case, Node.js), which then talks to the browser application (React, nuxtJS, Vue, etc.). So essentially you just need a backend server, which makes the API requests, and then your frontend makes GET/POST calls to that backend server.