Skip to content

Commit 85cf97f

Browse files
author
Bot
committedDec 21, 2020
fix dev server
1 parent 6d011c9 commit 85cf97f

File tree

4 files changed

+28
-31
lines changed

4 files changed

+28
-31
lines changed
 

‎.env.development

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VUE_APP_API_URL=http://localhost:3000

‎.github/workflows/push-controller.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
- name: Vue build
7070
if: env.all || env.frontend
7171
run: |
72-
npm run build:prod
72+
npm run build
7373
- name: Copy submitted code
7474
if: env.code_examples && !env.frontend
7575
run: |

‎server/server.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,9 @@ if (process.env.AUTO_PROMOTE) {
7878
const q = faunadb.query;
7979
const client = new faunadb.Client({ secret: PROD ? process.env.FAUNA_KEY : process.env.FAUNA_DEV_KEY });
8080

81-
app.enable('trust proxy'); // trust heroku and cloudflare
82-
app.use(bodyParser.urlencoded({ extended: false }));
83-
app.use(bodyParser.json());
84-
8581
let database = null;
8682
let stringifiedDB = '';
8783

88-
8984
const updateDatabaseCache = () => {
9085
stringifiedDB = JSON.stringify(database);
9186
};
@@ -163,21 +158,26 @@ if (process.env.AUTO_PROMOTE) {
163158
axios.get('https://coderushapi.ddns.net/ping').catch((err) => console.error(`Ping Error: ${err}`));
164159
}, 1000 * 60 * 10);
165160
} else {
161+
app.use((req, res, next) => {
162+
res.header('Access-Control-Allow-Origin', '*');
163+
res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');
164+
res.header('Access-Control-Allow-Headers', 'X-Requested-With, content-type, Authorization');
165+
166+
next();
167+
});
166168
app.use((req, res, next) => {
167169
if (!req.path.includes('code/') && (req.path.slice(-2) === 'js' || req.path.slice(-3) === 'css')) {
168170
res.header('content-encoding', 'gzip');
171+
console.log('gzip');
169172
}
173+
console.log('not gzip');
170174
next();
171175
});
172176
}
173177

174-
app.post(process.env.INDEX_HTML_UPDATE_URL, (req, res) => {
175-
if (updateIndexHtmlCache()) {
176-
res.sendStatus(201);
177-
} else {
178-
res.sendStatus(400);
179-
}
180-
});
178+
app.enable('trust proxy'); // trust heroku and cloudflare
179+
app.use(bodyParser.urlencoded({ extended: false }));
180+
app.use(bodyParser.json());
181181

182182
app.post(process.env.DATABASE_UPDATE_URL, (req, res) => {
183183
if (fetchDatabase()) {

‎vue.config.js

+14-18
Original file line numberDiff line numberDiff line change
@@ -66,30 +66,26 @@ module.exports = {
6666
// config.plugins.delete('prefetch');
6767
},
6868
devServer: {
69-
proxy: {
70-
'/data': {
71-
target: 'http://localhost:3000',
72-
secure: false,
73-
changeOrigin: true,
74-
},
69+
progress: true,
70+
clientLogLevel: 'info',
71+
72+
headers: {
73+
'Access-Control-Allow-Origin': '*',
74+
},
75+
before(app) {
76+
app.use((req, res, next) => {
77+
if (req.path.slice(0, 4) === '/cm/') {
78+
res.header('content-encoding', 'gzip');
79+
}
80+
next();
81+
});
7582
},
76-
// proxy: 'http://localhost:3000',
77-
// before(app) {
78-
// app.use((req, res, next) => {
79-
// if (req.path.slice(0, 4) === '/cm/') {
80-
// res.header('content-encoding', 'gzip');
81-
// }
82-
// next();
83-
// });
84-
// },
8583

86-
progress: true,
87-
compress: false,
84+
// compress: false,
8885
// https: {
8986
// key: fs.readFileSync(`${process.env.HOME}/localhost.key`),
9087
// cert: fs.readFileSync(`${process.env.HOME}/localhost.crt`),
9188
// ca: fs.readFileSync(`${process.env.HOME}/rootCA.crt`),
9289
// },
9390
},
94-
9591
};

0 commit comments

Comments
 (0)
Please sign in to comment.