A
Alokai•14mo ago
Altamash

CORS origin Error

Hello Guys when I try to fetch data using API i got same CROS origin error on console can you give some idea how to solve this error
No description
15 Replies
Altamash
AltamashOP•14mo ago
Hello @rohrig @skirianov sir can you please check once 😊
FabianClemenz
FabianClemenz•14mo ago
You need to add localhost to allowed origins on the magento cloudways app General speaking: it’s always best, to set these origins - on production, to only your frontend url In this case for localhost it needs the full domain + port: http://localhost:3000
Altamash
AltamashOP•14mo ago
i do that also but it did not fetch the product
Altamash
AltamashOP•14mo ago
@FabianClemenz what i have to do i have to fetch pop art categories product on this location that i mention on screen shot what can i do for that
No description
skirianov
skirianov•14mo ago
@Altamash it's hard to say what's going on exactly, are you fetching magento directly from frontend avoiding middleware?
Altamash
AltamashOP•14mo ago
@skirianov so what is simple way to fetch categories product on this page
skirianov
skirianov•14mo ago
can you show me how you fetch it? If we are talking about Nuxt2 version, you need to use our composables
skirianov
skirianov•14mo ago
Altamash
AltamashOP•14mo ago
@skirianov i try to fetch using magento API
No description
skirianov
skirianov•14mo ago
oh....you're not using Vue Storefront Middleware and composables? We have them prepared for you to handle all the requests and responses and they are covering most of the base use cases like fetching data and basically all other things
skirianov
skirianov•14mo ago
Please read this one https://docs.vuestorefront.io/magento/composition/composables.html Everything is already handled for you, unless you want something custom
Composables | Vue Storefront 2 for Magento
Documentation for the Magento connector for Vue Storefront 2
Altamash
AltamashOP•14mo ago
@skirianov i try to do it with middleware also but it not solved
No description
skirianov
skirianov•14mo ago
I'm a bit lost right now, sorry. What exactly are you trying to do. Is it something custom that is not handled by composables? I see you created a new ApiMethod, where do you call this method later on?
Altamash
AltamashOP•14mo ago
forget all other method @skirianov sir only what i have to do i want to fetch my pop art categories product so which is simple way to that
skirianov
skirianov•14mo ago
https://docs.vuestorefront.io/magento/composition/use-product.html#search-products This will get you a list of all products. You can filter products by categories by using filter option. getProductList({ filter: { category_uid: << INSERT THE CATEGORY UUID HERE >> } })
useProduct composable | Vue Storefront 2 for Magento
Documentation for the Magento connector for Vue Storefront 2
Want results from more Discord servers?
Add your server