File tree Expand file tree Collapse file tree 2 files changed +2
-17
lines changed Expand file tree Collapse file tree 2 files changed +2
-17
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ function _M.getPackage()
22
22
local uri = ngx .var .uri
23
23
local meta = ngx .shared .npmMeta
24
24
local body = meta :get (uri )
25
+ local base = ngx .var .scheme .. ' ://' .. ngx .var .http_host
25
26
-- yep, our own shared memory cache implementation :-/
26
27
if body == nil then
27
28
ngx .var .ephemeralCacheStatus = ' MISS'
@@ -39,17 +40,9 @@ function _M.getPackage()
39
40
else
40
41
ngx .var .ephemeralCacheStatus = ' HIT'
41
42
end
43
+ body = string.gsub (body , _M .hostPattern , base )
42
44
ngx .header [" Content-Length" ] = # body
43
45
ngx .print (body )
44
46
end
45
47
46
- function _M .filterPackageBody ()
47
- local npmConfig = ngx .shared .npmConfig
48
- local upstream = npmConfig :get (' npm_upstream_pattern' )
49
- -- need to construct URL because we may be proxying http<->https
50
- local base = ngx .var .scheme .. ' ://' .. ngx .var .http_host
51
- -- ngx.log(ngx.ERR, "Modifying JSON of " .. ngx.var.uri .. " to replace '" .. upstream .. "' with '" .. base .. "'")
52
- ngx .arg [1 ] = string.gsub (ngx .arg [1 ], upstream , base )
53
- end
54
-
55
48
return _M
Original file line number Diff line number Diff line change @@ -63,14 +63,6 @@ http {
63
63
proxy_buffers 32 1m ;
64
64
# need to disable encoding in order to be able to process it locally
65
65
proxy_set_header Accept-Encoding "" ;
66
- # modifying the response body will change the length
67
- header_filter_by_lua_block {
68
- ngx.header.content_length = nil
69
- }
70
- body_filter_by_lua_block {
71
- local ephemeralNPM = require "ephemeral-npm"
72
- ephemeralNPM.filterPackageBody()
73
- }
74
66
}
75
67
location @fetch-tgz {
76
68
internal ;
You can’t perform that action at this time.
0 commit comments