Skip to content

Commit 635ba23

Browse files
author
Ivan Beloborodov
committed
Third-party data file access #1099 https dev server
1 parent 429d9b2 commit 635ba23

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

src/config/dev.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import base from "./base";
22

3+
const pollingInterval = Number(__POLLING_INTERVAL__);
4+
35
const dev = {
46
apiUrl: "/api",
57
dev: true,
68
logMissingTranslations: true,
79
logGraphQLErrors: true,
8-
pollingInterval: 20000
10+
pollingInterval: pollingInterval ? pollingInterval * 1000 : 20000
911
};
1012

1113
export default {

webpack/server.js

+37-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const devServerConf = {
3030
}
3131
};
3232

33-
// Setup API proxy
33+
// Setup API and objects proxy
3434
if (process.env.PROD) {
3535
const { createProxyMiddleware } = require("http-proxy-middleware");
3636

@@ -42,6 +42,14 @@ if (process.env.PROD) {
4242
changeOrigin: true
4343
})
4444
);
45+
46+
app.use(
47+
"/objects",
48+
createProxyMiddleware({
49+
target: process.env.PROD,
50+
changeOrigin: true
51+
})
52+
);
4553
}
4654

4755
const devMiddleWare = require("webpack-dev-middleware")(compiler, devServerConf);
@@ -62,4 +70,31 @@ app.get("*", (req, res) => {
6270
});
6371
});
6472

65-
app.listen(port);
73+
if (process.env.HTTPS_CRT)
74+
{
75+
const fs = require('fs');
76+
77+
const cert = fs.readFileSync(process.env.HTTPS_CRT, 'utf8');
78+
const key = fs.readFileSync(process.env.HTTPS_KEY, 'utf8');
79+
80+
const http = require('http');
81+
const https = require('https');
82+
83+
const url = require('url');
84+
85+
(http
86+
.createServer((req, res) => {
87+
const u = new url.URL('http://' + req.headers['host'] + req.url);
88+
u.protocol = 'https:';
89+
u.port = port + 1;
90+
res.writeHead(301, {"Location": u.toString()});
91+
res.end();
92+
})
93+
.listen(port));
94+
95+
(https
96+
.createServer({key, cert}, app)
97+
.listen(port + 1));
98+
}
99+
else
100+
app.listen(port);

webpack/webpack.dev.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ base.plugins.push(
6161
new webpack.DefinePlugin({
6262
"process.env.NODE_ENV": JSON.stringify("development"),
6363
__VERSION__: JSON.stringify(_.versionString),
64-
__BUILD_YEAR__: JSON.stringify(_.buildYear)
64+
__BUILD_YEAR__: JSON.stringify(_.buildYear),
65+
__POLLING_INTERVAL__: JSON.stringify(process.env.POLLING_INTERVAL)
6566
}),
6667
new webpack.HotModuleReplacementPlugin(),
6768
new ReactRefreshWebpackPlugin(),

0 commit comments

Comments
 (0)