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

Create setup switch for local dev setup and deployed setup #327

Open
codingfabi opened this issue Jul 1, 2023 · 3 comments
Open

Create setup switch for local dev setup and deployed setup #327

codingfabi opened this issue Jul 1, 2023 · 3 comments
Labels
Discussion Thinks that need to be discussed operations consists of all issues that regard application building and hosting

Comments

@codingfabi
Copy link
Contributor

Currently we root the backend requests in the apollo client dependent on the environment variable NEXT_PUBLIC_DEV:

JSON.parse(process.env.NEXT_PUBLIC_DEV ? process.env.NEXT_PUBLIC_DEV  as string : 'false' ) ? `http://localhost:8000/graphql/` : `https://api.test-pledge4future.heigit.org/graphql/`

This could lead to problems when deploying the software on the production service because https://api.test-pledge4future.heigit.org/graphql/ will then no longer be the valid url for the backend.

To overcome this problem, I suggest to remove the NEXT_PUBLIC_DEV environment variable and introduce a new one called 'NEXT_PUBLIC_INSTANCE`. We can then specify a string for this variable that specifies, wether the application is hosted in a local dev setup, in the test instance or the production instance.

We define three valid strings: p4f-local, p4f-test and p4f-prod. With these values, we can then get the following constellations with the resulting API url defined by a function that looks like this:

function getURLApi(){
     switch(process.env.NEXT_PUBLIC_DEV):
               case 'p4f-local':
                          return 'http://localhost:8000/graphql/'
                case 'p4f-test':
                           return 'https://api.test-pledge4future.heigit.org/graphql/'
                case 'p4f-prod:
                           return 'https://api.pledge4future.heigit.org/graphql/'
}
@codingfabi
Copy link
Contributor Author

@redfrexx @sami1riaz let me know what you guys think :)

@codingfabi codingfabi added operations consists of all issues that regard application building and hosting Discussion Thinks that need to be discussed labels Jul 1, 2023
@redfrexx
Copy link
Member

redfrexx commented Jul 5, 2023

Sounds good! I think it would be good to put the URLS into the .env file as well, so that in case we have to change them we don't have to search in the code.

@redfrexx
Copy link
Member

redfrexx commented Jul 5, 2023

We could also shorten them to local, test and prod.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion Thinks that need to be discussed operations consists of all issues that regard application building and hosting
Projects
None yet
Development

No branches or pull requests

2 participants