johannschopplich / cacao-kit-frontend

🍫 Best practice Nuxt and KQL starter for your headless Kirby CMS
https://cacao-kit.byjohann.dev
MIT License
30 stars 3 forks source link

Fresh install questions #4

Closed antoine3000 closed 6 months ago

antoine3000 commented 6 months ago

Hi Johann,

First of all, thank you so much for the work you do for the Kirby community, I really appreciate it!

I wanted to try a fresh install of the Cacao kit on my local machine and start developing from there before pushing everything to the remote. Unfortunately, I can't get it to work and reading the docs doesn't help my case.

  1. I've cloned the the cacao-kit-frontend into a folder
  2. I've cloned the the cacao-kit-backend into another folder

Both should be accessible in the browser as cacao-kit-frontend.test and cacao-kit-backend.test.

In the frontend, my .env looks like this:

NUXT_PUBLIC_SITE_URL=cacao-kit-frontend.test
KIRBY_BASE_URL=http://localhost:3000
KIRBY_API_TOKEN=test

And for the backend, my .env looks like this:

KIRBY_DEBUG=true
KIRBY_PANEL_INSTALL=true
KIRBY_CACHE=false
KIRBY_MULTILANG=true

KIRBY_HEADLESS_API_TOKEN=test
KIRBY_HEADLESS_ALLOW_ORIGIN=*
KIRBY_HEADLESS_FRONTEND_URL=http://localhost:3000

I was expecting it to work from there, but it doesn't. Could you give me some guidance on how to make it work locally? Thanks a lot, Antoine

johannschopplich commented 6 months ago

Hi there!

Nuxt runs on localhost:3000. If you point the KIRBY_BASE_URL environment variable to the same hostname, Nuxt will try to fetch Kirby data from itself. Instead, you need to point to your backend instance. Depending on if you use Valet, composer start the URL will be something like http://cacao-kit-backend.test or http://localhost:8000, respectively.

Take this demo configuration as an example:

NUXT_PUBLIC_SITE_URL=http://localhost:3000
KIRBY_BASE_URL=http://cacao-kit-backend.test
KIRBY_API_TOKEN=test

Edit: Updated the config to match your setup.

antoine3000 commented 6 months ago

Ay, makes sense, many thanks!