forked from u4bi-store/aws-lambda-ssr-poc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
66 lines (40 loc) · 1.11 KB
/
app.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
64
65
66
const express = require('express')
const assets = require('./build/assets.json')
const renderScripts = require('./common/render/scripts')
const renderStyles = require('./common/render/styles')
const app = express()
var flag = 'aa'
app.use(express.static(`${__dirname}/build`))
app.use((req, res, next) => {
// res.setHeader('Access-Control-Allow-Origin', '*')
res.setHeader('X-TEST-HEADER', 'TEST')
flag = 'bb'
next()
})
app.get('/', (req, res) => {
// res.setHeader('Content-Type', 'text/html')
res
.status(200)
.send(
`<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>lambda-custom-domain</title>
${ renderStyles(assets) }
${ renderScripts(assets) }
</head>
<body>
<div id="root">
<h1>ssr markup ${ flag }</h1>
<img src="logo.png" />
</div>
</body>
</html>`
)
})
app.get('/test', (req, res) => {
// res.setHeader('Content-Type', 'application/json')
res.json({ message: 'test api' })
})
module.exports = app