Skip to content
This repository has been archived by the owner on Jun 10, 2021. It is now read-only.

Self hosted frontend still try to connect api.bullet-train.io/api/v1/flags/ #18

Closed
coolcodr opened this issue May 25, 2020 · 4 comments
Closed

Comments

@coolcodr
Copy link

Hi bullet-train developers, it is a great project.

I am try to run bullet-train-api and bullet-train-frontend locally, and I edited the file env/project_dev.js api to my local server in bullet-train-frontend and run it using npm run dev.

Most of the functions seem working fine, except I found it keep calling https://api.bullet-train.io/api/v1/flags/ to retrieve feature flags. May I know which part of the config I am missing, so that it can get the flags from my local server?

@kyle-ssg
Copy link
Member

kyle-ssg commented May 25, 2020

Hey, glad you like the project!

I think the reason for this is quite straight forward. Although you are calling your API in order for the frontend to function, this project also uses the Bullet Train SDK in order to control what features are visible to the frontend (See bulletTrain in project.js, this is an environment key straight from bullet-train.io).

These calls you are seeing are those to bullet train from the js client in order to see what features to show.

https://github.com/BulletTrainHQ/bullet-train-frontend/blob/master/common/stores/config-store.js Is where this is managed.

@kyle-ssg
Copy link
Member

kyle-ssg commented May 25, 2020

You can switch this to use your stack entirely by creating a project in your infrastructure and replicate the flags mentioned in the readme (https://gist.github.com/kyle-ssg/4c65b4185d0fe3ae35f73244de5e2fef), then update the bulletTrain key in project.js and update bulletTrain.init in the project to use your api

bulletTrain.init({
  environmentID: Project.bulletTrain
  api: yourAPIURL
  ...
})

Edit: Pinning issue, think that documentation could be improved here to clear up confusion.

@kyle-ssg kyle-ssg pinned this issue May 25, 2020
@coolcodr
Copy link
Author

Thanks @kyle-ssg, I don't know which part going wrong, I have tried set the API_URL env variable, update the env/project_dev.js and project.js, but my local bullet-train-frontend still trying to connect https://api.bullet-train.io/api/v1/flags/, for other endpoints it will call my local server.

Is there any js files I need to re-build?

@coolcodr
Copy link
Author

I got it sorted, thank you for pointing me the file: https://github.com/BulletTrainHQ/bullet-train-frontend/blob/master/common/stores/config-store.js, I specify api to my local server and it works now.

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

No branches or pull requests

2 participants