Giter VIP home page Giter VIP logo

Comments (4)

Laurynas-Sirgedas avatar Laurynas-Sirgedas commented on May 22, 2024

An issue occurred because I've followed all instructions and set the WordPress site address to http://localhost:3000
When I set the Site address (frontend) to a normal domain (the same as WordPress Address) address, then the issue disappears

from nextjs-woocommerce-restapi.

GPorter43 avatar GPorter43 commented on May 22, 2024

Is there a more elegant solution to this as using the normal WordPress address will cause the permalinks to link to the wordpress site not the headless Nextjs site

from nextjs-woocommerce-restapi.

imranhsayed avatar imranhsayed commented on May 22, 2024

@Laurynas-Sirgedas , @GPorter43

  • Thanks for bringing this up 👍
  • When we set site address url to frontend url, by default wp rest endpoint gets that frontend url as base point.
  • So an actual backend url required an update for REST api only. I have made the changes to the Headlesss CMS Plugin

So this is resolved, Please pull the latest changes from https://github.com/imranhsayed/headless-cms or download the latest version of the plugin.
Now you should be able to set the SITE URL to the front end url from WordPress General Settings
image

image

from nextjs-woocommerce-restapi.

renjogabro avatar renjogabro commented on May 22, 2024

@Laurynas-Sirgedas , @GPorter43

  • Thanks for bringing this up 👍
  • When we set site address url to frontend url, by default wp rest endpoint gets that frontend url as base point.
  • So an actual backend url required an update for REST api only. I have made the changes to the Headlesss CMS Plugin

So this is resolved, Please pull the latest changes from https://github.com/imranhsayed/headless-cms or download the latest version of the plugin. Now you should be able to set the SITE URL to the front end url from WordPress General Settings image

image

@imranhsayed,
Many thanks for the wonderful work.
However, this is not resolved for me, even though I have the latest version of HCMS. When I set site to localhost:3000 in Wordpress General settings, I get the same result of

{ success: false, products: [ ], error: "Request failed with status code 401", }
when I try to reach: http://localhost:3000/api/get-products

It was the same for trying to use function getStaticProps() with this endpoint: /wp-json/rae/v1/header-footer?header_location_id=hcms-menu-header&footer_location_id=hcms-menu-footer.
However, this particular problem was solved by adding "index.php" in url, like so:

/index.php/wp-json/rae/v1/header-footer?header_location_id=hcms-menu-header&footer_location_id=hcms-menu-footer

But still not elegant, and would be perfect if this was resolved with the Wordpress General settings.

Any chance you could look into this?

from nextjs-woocommerce-restapi.

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.