-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
50 lines (44 loc) · 1.34 KB
/
index.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
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable max-len */
//const functions = require("firebase-functions");
// import from a specific subpackage
const { onRequest } = require('firebase-functions/v2/https');
const next = require('next');
//const http = require('http');
// import path = require("path");
const isDev = process.env.NODE_ENV !== 'production';
const server = next({
dev: isDev,
// location of .next generated after running -> yarn build
conf: { distDir: '.next' },
});
const nextjsHandle = server.getRequestHandler();
// functions.runWith({
// // Keep 1 instances warm for this latency-critical function
// minInstances: 1,
// }).https.onRequest(
exports.nextjs = onRequest(
{
minInstances: 1,
memory: '2GiB',
concurency: 1000,
},
(req, res) => {
// https://firebase.google.com/docs/hosting/manage-cache
res.set('Cache-Control', 'public, max-age=3000, s-maxage=6000');
return server.prepare().then(() => nextjsHandle(req, res));
}
);
exports.nextjseurope = onRequest(
{
minInstances: 1,
memory: '2GiB',
concurency: 1000,
region: 'europe-west1',
},
(req, res) => {
// https://firebase.google.com/docs/hosting/manage-cache
res.set('Cache-Control', 'public, max-age=3000, s-maxage=6000');
return server.prepare().then(() => nextjsHandle(req, res));
}
);