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

ability to configure API_URL without rebuild #239

Open
legendar opened this issue May 25, 2020 · 2 comments
Open

ability to configure API_URL without rebuild #239

legendar opened this issue May 25, 2020 · 2 comments
Milestone

Comments

@legendar
Copy link
Contributor

due to optimization purpose we want to do one time build for all environments (prod, stage, dev).
in multi-domain system we want to set API_URL on the app run phase.
as a proposal solution we can use separate JS file generated on backend, e.g:

// /app-config.js
window.APP_CONFIG = {
  API_URL: 'https://custom-domain.example.com/custom-sub-url/v1'
}
@legendar legendar added this to the v5 milestone May 25, 2020
@romanosipenko
Copy link
Contributor

Or use sed to replace placeholders with actual params on start-up

@Pareder
Copy link
Contributor

Pareder commented Jul 23, 2021

Some explanation of legendar comment:

  1. backend developers create custom endpoint (for example app-config.js) with such code:
window.APP_CONFIG = {
 ENV_VARIABLE: "{{ ENV_VARIABLE|setting }}"
}
  1. frontend developers include this endpoint like a synchronous script BEFORE all bundle files:
<script type="text/javascript" src="./app-config.js"></script>
<script type="text/javascript" src="./bundle.js"></script>
  1. frontend developers use in code window.APP_CONFIG.ENV_VARIABLE instead of process.env.ENV_VARIABLE.

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

No branches or pull requests

3 participants