Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
6d6ef1ca
Commit
6d6ef1ca
authored
Jan 03, 2017
by
Arunoda Susiripala
Committed by
Guillermo Rauch
Jan 03, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove the use of fs.access (#625)
parent
01a17738
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
8 deletions
+2
-8
render.js
server/render.js
+2
-8
No files found.
server/render.js
View file @
6d6ef1ca
import
{
join
}
from
'path'
import
{
createElement
}
from
'react'
import
{
renderToString
,
renderToStaticMarkup
}
from
'react-dom/server'
import
fs
from
'mz/fs'
import
send
from
'send'
import
accepts
from
'accepts'
import
requireModule
from
'./require'
...
...
@@ -150,16 +149,11 @@ export async function serveStaticWithGzip (req, res, path) {
try
{
const
gzipPath
=
`
${
path
}
.gz`
// fs.access before a file read is not recommeded due to race conditions.
// But in this case, this is totally fine because we know
// it's impossible to have a race condition like that.
// (Since we gzip AOT when called `next build`)
await
fs
.
access
(
gzipPath
,
fs
.
constants
.
R_OK
)
res
.
setHeader
(
'Content-Encoding'
,
'gzip'
)
return
serveStatic
(
req
,
res
,
gzipPath
)
await
serveStatic
(
req
,
res
,
gzipPath
)
}
catch
(
ex
)
{
if
(
ex
.
code
===
'ENOENT'
)
{
res
.
removeHeader
(
'Content-Encoding'
)
return
serveStatic
(
req
,
res
,
path
)
}
throw
ex
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment