/
server.js
64 lines (41 loc) · 1.48 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'use strict';
/**
* Use `server.js` to run your application without `$ strapi start`.
* To start the server, run: `$ npm start`.
*
* This is handy in situations where the Strapi CLI is not relevant or useful.
*/
process.chdir(__dirname);
const express = require("express");
const proxy = require("express-http-proxy");
const strapi = require('strapi');
let app = express();
// ========================
// Google analytics proxy
// ========================
function getIpFromReq (req) { // get the client's IP address
var bareIP = ":" + ((req.connection.socket && req.connection.socket.remoteAddress)
|| req.headers["x-forwarded-for"] || req.connection.remoteAddress || "");
return (bareIP.match(/:([^:]+)$/) || [])[1] || "127.0.0.1";
}
app.use("/", proxy("www.google-analytics.com", {
proxyReqPathResolver: function (req) {
return req.url + (req.url.indexOf("?") === -1 ? "?" : "&")
+ "uip=" + encodeURIComponent(getIpFromReq(req));
}
}));
app.listen(6868);
// TODO:
// GOOGLE ANALYTICS PROXY ON :80/analytics
// SETUP NGINX STATIC SERVER ON :80 /public
// SSR CATCH ALL ROUTE ON :80/*
// AND STRAPI ON :1337 (disable strapi static files server)
// (should work without JS (no interaction but ok visuals))
// Front:
// preview hover links (svg icons)
// conditionnal infos in popup
// Requirements list for submission
// max img size & img resolution?
// next / prev arrows in popup
// better animations (cubic beziers anims, xbox style)
strapi.start();