FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
razzle/examples/basic-server/src/server.js at master · javascriptit/razzle · GitHub
javascriptit
razzle
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
razzle
/
examples
/
basic-server
/
src
/
server.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
38 lines (31 loc) · 848 Bytes
Breadcrumbs
razzle
/
examples
/
basic-server
/
src
/
server.js
Copy path
File metadata and controls
38 lines (31 loc) · 848 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
App
from
'./App'
;
import
React
from
'react'
;
import
express
from
'express'
;
import
{
renderToString
}
from
'react-dom/server'
;
export
const
renderApp
=
(
req
,
res
)
=>
{
const
markup
=
renderToString
(
<
App
/>
)
;
const
html
=
// prettier-ignore
`<!doctype html>
<html lang="">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charSet='utf-8' />
<title>Welcome to Razzle</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id="root">
${
markup
}
</div>
</body>
</html>`
;
return
{
html
}
;
}
;
const
server
=
express
(
)
;
server
.
disable
(
'x-powered-by'
)
.
use
(
express
.
static
(
process
.
env
.
RAZZLE_PUBLIC_DIR
)
)
.
get
(
'/*'
,
(
req
,
res
)
=>
{
const
{
html
}
=
renderApp
(
req
,
res
)
;
res
.
send
(
html
)
;
}
)
;
export
default
server
;
Back
|
FazBrowse Home
|
New Git URL