I manage an existing ecommerce site that lives on an nginx/apache server, and the host is also the provider of the ecommerce system we're using. I'd like to turn the ecommerce system into a headless CMS, using React with NextJS for the front end.
Is it possible to make this work somehow, all on the same server?
Some notes about the current setup:
- The site lives on a
www
subdomain, and it's well established so I don't want to change that
- The ecommerce system uses session cookies that are http-only, secure, and also on the
www
subdomain
- the site is served via
https
and must remain that way
- the server is running nginx and apache, and most pages are served by nginx.
- I'm not sure about the specifics of the config. I know the host prefers nginx for speed purposes, but kept apache in place because so many of their clients are dependent on .htaccess
My idea is to set up an api page in the ecommerce system, and all communication between it and React will go through the api page. The cart will be responsible for managing the user's session the way it always has, via cookies. I'll just send post
and get
requests to the api page, and I'll set it up to send back a json response with whatever it says is going on (user is logged in, here are the cart contents, etc).
Maybe we can make some port adjustments so the ecommerce system lives on different ports than Node?
One last option is to put the ecommerce system on a subdomain such as cart.example.com
, and give www
to Node. I'd need to figure out a way to make the cart put it's cookies on www
, which I'm not sure is possible.