Config set from server
Summary: Instead of having duplicate configs defined on our HTML. Move the config definition to the server. Reviewed By: aigoncharov Differential Revision: D51307092 fbshipit-source-id: 68f4afc918cf191b3a15b3981429c5a05d5df8df
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9166939214
commit
7de92cb34a
@@ -29,6 +29,8 @@ import {sessionId} from '../sessionId';
|
|||||||
import {UIPreference, openUI} from '../utils/openUI';
|
import {UIPreference, openUI} from '../utils/openUI';
|
||||||
import {processExit} from '../utils/processExit';
|
import {processExit} from '../utils/processExit';
|
||||||
|
|
||||||
|
import util from 'node:util';
|
||||||
|
|
||||||
type Config = {
|
type Config = {
|
||||||
port: number;
|
port: number;
|
||||||
staticPath: string;
|
staticPath: string;
|
||||||
@@ -160,14 +162,24 @@ async function startHTTPServer(
|
|||||||
? path.join(config.staticPath, config.entry)
|
? path.join(config.staticPath, config.entry)
|
||||||
: path.join(config.staticPath, 'loading.html');
|
: path.join(config.staticPath, 'loading.html');
|
||||||
const token = await getAuthToken();
|
const token = await getAuthToken();
|
||||||
|
|
||||||
|
const flipperConfig = {
|
||||||
|
theme: 'light',
|
||||||
|
entryPoint: isProduction()
|
||||||
|
? 'bundle.js'
|
||||||
|
: 'flipper-ui-browser/src/index-fast-refresh.bundle?platform=web&dev=true&minify=false',
|
||||||
|
debug: !isProduction(),
|
||||||
|
graphSecret: GRAPH_SECRET,
|
||||||
|
appVersion: environmentInfo.appVersion,
|
||||||
|
sessionId: sessionId,
|
||||||
|
unixname: environmentInfo.os.unixname,
|
||||||
|
authToken: token,
|
||||||
|
};
|
||||||
|
|
||||||
fs.readFile(resource, (_err, content) => {
|
fs.readFile(resource, (_err, content) => {
|
||||||
const processedContent = content
|
const processedContent = content
|
||||||
.toString()
|
.toString()
|
||||||
.replace('GRAPH_SECRET_REPLACE_ME', GRAPH_SECRET)
|
.replace('FLIPPER_CONFIG_PLACEHOLDER', util.inspect(flipperConfig));
|
||||||
.replace('FLIPPER_APP_VERSION_REPLACE_ME', environmentInfo.appVersion)
|
|
||||||
.replace('FLIPPER_UNIXNAME_REPLACE_ME', environmentInfo.os.unixname)
|
|
||||||
.replace('FLIPPER_AUTH_TOKEN_REPLACE_ME', token)
|
|
||||||
.replace('FLIPPER_SESSION_ID_REPLACE_ME', sessionId);
|
|
||||||
res.end(processedContent);
|
res.end(processedContent);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,16 +14,7 @@
|
|||||||
|
|
||||||
<title>Flipper</title>
|
<title>Flipper</title>
|
||||||
<script>
|
<script>
|
||||||
window.flipperConfig = {
|
window.flipperConfig = FLIPPER_CONFIG_PLACEHOLDER;
|
||||||
theme: 'light',
|
|
||||||
entryPoint: 'flipper-ui-browser/src/index-fast-refresh.bundle?platform=web&dev=true&minify=false',
|
|
||||||
debug: true,
|
|
||||||
graphSecret: 'GRAPH_SECRET_REPLACE_ME',
|
|
||||||
appVersion: 'FLIPPER_APP_VERSION_REPLACE_ME',
|
|
||||||
sessionId: 'FLIPPER_SESSION_ID_REPLACE_ME',
|
|
||||||
unixname: 'FLIPPER_UNIXNAME_REPLACE_ME',
|
|
||||||
authToken: 'FLIPPER_AUTH_TOKEN_REPLACE_ME',
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
.message {
|
.message {
|
||||||
|
|||||||
@@ -14,16 +14,7 @@
|
|||||||
|
|
||||||
<title>Flipper</title>
|
<title>Flipper</title>
|
||||||
<script>
|
<script>
|
||||||
window.flipperConfig = {
|
window.flipperConfig = FLIPPER_CONFIG_PLACEHOLDER;
|
||||||
theme: 'light',
|
|
||||||
entryPoint: 'bundle.js',
|
|
||||||
debug: false,
|
|
||||||
graphSecret: 'GRAPH_SECRET_REPLACE_ME',
|
|
||||||
appVersion: 'FLIPPER_APP_VERSION_REPLACE_ME',
|
|
||||||
sessionId: 'FLIPPER_SESSION_ID_REPLACE_ME',
|
|
||||||
unixname: 'FLIPPER_UNIXNAME_REPLACE_ME',
|
|
||||||
authToken: 'FLIPPER_AUTH_TOKEN_REPLACE_ME',
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
.message {
|
.message {
|
||||||
|
|||||||
Reference in New Issue
Block a user