postlight / headless-wp-starter

🔪 WordPress + React Starter Kit: Spin up a WordPress-powered React app in one step
https://archive.postlight.com/labs/wordpress-react-starter-kit
GNU General Public License v2.0
4.48k stars 650 forks source link

Hosting deploy #145

Open Emiliano-Bucci opened 5 years ago

Emiliano-Bucci commented 5 years ago

Hi to all, actually i'm developing a blog (an existing blog hosted in Siteground) using Next.js, GraphQL, Apollo, ecc (based on postlight structure) and i'm trying to understand one thing: is there a way to deploy my app, keeping actual urls intact? The problem is that Siteground doesn't support Node on shared hosting.

Thanks!

freddiemixell commented 5 years ago

@Emiliano-Bucci Siteground does have hosting for node but you're going to be much better off hosting this with Zeit's now. You should keep your WordPress install on siteground and use that as the api to feed your react frontend on Now.

Emiliano-Bucci commented 5 years ago

@freddiemixell That's what i taught: Is there a way, by doing this, to keep the urls intact? Maybe a complete dns / 301 redirect to my now instance?

cr101 commented 5 years ago

Maintaining and paying for two separate hosting environments is not ideal

jacobmishkin commented 5 years ago

Now is updated to 2.0 and with new pricing. I'd check that first, but I would follow what @freddiemixell said and host the WP backend on SiteGround then Host your frontend on Now. It might be free. Once deployed you can alias the frontend from the Now URL to the URL of your choice. If you are going to deploy the frontend to Now with Docker, I'd look into updating the docker file provided, to use an updated alpine version of node. You need to make sure your Docker image is below the requirements for the free hosting. Hope this helps.

cr101 commented 5 years ago

@jacobmishkin is it possible to host both the frontend and the WP backend on Now 2.0? The URL for the frontend would be https://mywebapp.com and the URL for the WP backend would be https://wp.mywebapp.com

jacobmishkin commented 5 years ago

@cr101 From there docs it looks like you can deploy PHP7, not sure about the database though, but here is an example from now to deploy a WP site: https://github.com/now-examples/wordpress

Couple of things you'll need to do is in the WP backend in the inc folder under the frontend-orgin.php file make sure that is the URL for the frontend.

In the frontend folder change the config.js file to the URL of your backend.

To deploy WP to now, I'd take a look at the example, but it should work.

After you deploy, you'll just need to alias the given now URL to the domain you want to use, and that should work.

cr101 commented 5 years ago

I'm not sure that the example works with Now 2.0

I will link to this issue for reference.

Emiliano-Bucci commented 5 years ago

@jacobmishkin Hi! I follow the steps you suggest (creating an alias from now to the wordpress root hosting url) though i cannot access anymore to the admin section. Is there a way to accomplish that? I think is because my url now points to the now deployment :/ Thanks!