0

I have found many articles about headless wordpress and vue.js using data via WP REST API. In these articles they deploy the app on separate servers. Backend is on different server than frontend. I'm trying to find out how to deploy the app on one server.

Until now I come up with one solution: On the server create subfolder ( subdomain ) for CMS and on public upload the Vue frontend and pull the data from subdomain via WP REST API endpoint.

Is it possible to connect Wordpress and Vue without creating subdomain? I would like to upload the vue app right in the folder where is Wordpress. I think I can't put it in the theme folder of the wordpress and keep it separate at the same time. Any solutions?

1

Yes, it is possible to connect WordPress and Vue without a subdomain. As you're pulling data via the WP REST API it doesn't matter where WP is - same or different server, subdomain or subfolder - as long as you know its url.

You could have your Vue related files (e.g. index.html, app.css, and app.js) for example in /public_html and WP installed in /public_html/wp folder. You could then access WP from youdomain.com/wp and your app would be in yourdomain.com.

Mixing WP files and your Vue app files probably isn't a good idea as WP needs its index.php to function properly. But you could create a theme with just a index.php file in it, which would load your app scripts and the app root (i.e. <div id="app"></div>) element.

| improve this answer | |
  • Thank you very much! – trenccan Sep 14 '19 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.