Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch backend url #11

Open
bjarman opened this issue Nov 4, 2019 · 15 comments
Open

Switch backend url #11

bjarman opened this issue Nov 4, 2019 · 15 comments

Comments

@bjarman
Copy link

bjarman commented Nov 4, 2019

Hi! This is not an issue but rather a question. I am successfully running the recipe demo locally and also the contenta cms both in docker.

I would like to connect the contenta_react_next to my local contenta cms to retrieve the recipes from the content there.

I have tried to accomplish this by changing the BACKEND_URL in my .env file and then doing make install and make up but the react interface still gets the content from the remote cms.

What must I do to get this working?

@spleshka
Copy link
Member

spleshka commented Nov 4, 2019

Hi @bjarman, basically, all you need to do is to change the BACKEND_URL in .env file and then run make down following by make up, no need to reinstall the project. It should work!

@bjarman
Copy link
Author

bjarman commented Nov 4, 2019

I have tried this but the content is still fetched from https://live-contentacms.pantheonsite.io/api/recipes and not from my local cms.
Could this be a docker issue?
How should the BACKEND_URL look for the conecta_react_next container to reach my contenta_cms container? I can reach them both using "localhost" but on different ports. But can one container actually reach the other using localhost?

@spleshka
Copy link
Member

spleshka commented Nov 4, 2019

Hm, that's the only place that holds the URL of the backend. Alright, try docker-compose down and then make up again. Also, make sure you're modifying the value of .env and not .env.default file.

@bjarman
Copy link
Author

bjarman commented Nov 4, 2019

..actually. The BACKEND_URL is set in package.json - this is where i have made changes like so:
"env": {
"BACKEND_URL": "http://localhost:84",
"JSONAPI_PREFIX": "/api"
}

Both containers are on my localhost, on different ports, but are the containers aware of each other is what I mean. A container issue rather than an issue with react or cms?

@spleshka
Copy link
Member

spleshka commented Nov 4, 2019

In package.json the env vars are just for now.sh environment, it does not affect your local environment.

@bjarman
Copy link
Author

bjarman commented Nov 4, 2019

There is no BACKEND_URL variable in .env file. Should I add it manually?

@spleshka
Copy link
Member

spleshka commented Nov 4, 2019

Are you sure you're looking at reactjs/.env and not the .env in the root of the repo?

@bjarman
Copy link
Author

bjarman commented Nov 4, 2019

I have changed there as well but no change. Content is still from remote cms.

@spleshka
Copy link
Member

spleshka commented Nov 4, 2019

what's the output if you log into the container with docker-compose exec node bash and then echo $BACKEND_URL ?

@bjarman
Copy link
Author

bjarman commented Nov 4, 2019

That echoes nothing. However looking in the .env file from within the container it has the correct BACKEND_URL. Very strange.

@spleshka
Copy link
Member

spleshka commented Nov 4, 2019

Looks like you have some issues with your local set up. Not sure if I can help here, it requires a bit of debugging on your local.

@bjarman
Copy link
Author

bjarman commented Nov 4, 2019

But how come that even though the .env file has the correct url but still gets the content from the live.contentacms site? That should be impossible right?

@bjarman
Copy link
Author

bjarman commented Nov 4, 2019

I will start over with my local environment from scratch and see what happens. Still a bit mysterious though. If you leave this issue open for a few days I will post back and let you know how it turns out and if I find out what was wrong.

@timrabbetts
Copy link

I've got the react frontend spun up working great but cant figure out how to point to my local backend, I've scanned code for pantheon, replaced every URL, run make down, make install, make up and it's still connecting to pantheon, can you help?

@spleshka
Copy link
Member

@timrabbetts as far as I recall, you need to change the URL in the .env file in the root of the repository and then restart the environment (make restart).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants