add beta site redirect on cookie value
This commit is contained in:
parent
ceeb8a406d
commit
c11c5a7a2b
2 changed files with 21 additions and 7 deletions
|
|
@ -340,6 +340,21 @@ function rewrite(req, res, next) {
|
||||||
* @param {Function} next
|
* @param {Function} next
|
||||||
*/
|
*/
|
||||||
function setup(req, res, next) {
|
function setup(req, res, next) {
|
||||||
|
let host = req.headers['host'] || '',
|
||||||
|
beta = getCookieValue(req.headers['cookie'],'beta');
|
||||||
|
|
||||||
|
if (beta === 'true' && req.url.indexOf('?nobeta') > 0) {
|
||||||
|
res.setHeader('Set-Cookie', 'beta=false; path=/;');
|
||||||
|
beta = 'false';
|
||||||
|
} else if (beta !== 'true' && req.url.indexOf('?beta') > 0) {
|
||||||
|
res.setHeader('Set-Cookie', 'beta=true; path=/;');
|
||||||
|
beta = 'true';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (beta === 'true' && host.indexOf('beta.') !== 0) {
|
||||||
|
return redirect(res, `//beta.${host}${req.url}`);
|
||||||
|
}
|
||||||
|
|
||||||
let parsed = url.parse(req.url, true),
|
let parsed = url.parse(req.url, true),
|
||||||
ipaddr = remoteIP(req),
|
ipaddr = remoteIP(req),
|
||||||
dbikey = db.key(["ip",ipaddr]),
|
dbikey = db.key(["ip",ipaddr]),
|
||||||
|
|
|
||||||
|
|
@ -40,11 +40,11 @@
|
||||||
<!-- all modal dialogs -->
|
<!-- all modal dialogs -->
|
||||||
<div id="modal">
|
<div id="modal">
|
||||||
<div id="help">
|
<div id="help">
|
||||||
<a href="https://en.wikipedia.org/wiki/Slicer_(3D_printing)">wikipedia</a>
|
<a href="https://en.wikipedia.org/wiki/Slicer_(3D_printing)">wikipedia</a>
|
||||||
<a href="https://www.onshape.com/cad-blog/partner-spotlight-kirimoto">Onshape</a>
|
<a href="https://www.onshape.com/cad-blog/partner-spotlight-kirimoto">Onshape</a>
|
||||||
<a href="https://www.inov3d.net/3d-printing-slicer-software-download/">slicer news</a>
|
<a href="https://www.inov3d.net/3d-printing-slicer-software-download/">slicer news</a>
|
||||||
<a href="https://sienci.com/2016/08/24/the-story-of-kirimoto/">Sienci Labs</a>
|
<a href="https://sienci.com/2016/08/24/the-story-of-kirimoto/">Sienci Labs</a>
|
||||||
<a href="https://www.youtube.com/watch?v=IZ1VG07oFCo">Teaching Tech</a>
|
<a href="https://www.youtube.com/watch?v=IZ1VG07oFCo">Teaching Tech</a>
|
||||||
</div>
|
</div>
|
||||||
<!-- changeable print dialog -->
|
<!-- changeable print dialog -->
|
||||||
<div id="print"></div>
|
<div id="print"></div>
|
||||||
|
|
@ -52,8 +52,7 @@
|
||||||
<div id="local" class="dialog">
|
<div id="local" class="dialog">
|
||||||
<button id="local-close" class="modal-x">X</button>
|
<button id="local-close" class="modal-x">X</button>
|
||||||
<center><b><u>Grid.Local Devices</u></b></center>
|
<center><b><u>Grid.Local Devices</u></b></center>
|
||||||
<br>
|
<br><div id="local-dev" class="flow-col"></div>
|
||||||
<div id="local-dev" class="flow-col"></div>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- hidden file input loader -->
|
<!-- hidden file input loader -->
|
||||||
<input id="load-file" type="file" name="loadme" style="display:none" accept=".stl,.gcode,.nc"/>
|
<input id="load-file" type="file" name="loadme" style="display:none" accept=".stl,.gcode,.nc"/>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue