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()
2222 local uri = ngx .var .uri
2323 local meta = ngx .shared .npmMeta
2424 local body = meta :get (uri )
25+ local base = ngx .var .scheme .. ' ://' .. ngx .var .http_host
2526 -- yep, our own shared memory cache implementation :-/
2627 if body == nil then
2728 ngx .var .ephemeralCacheStatus = ' MISS'
@@ -39,17 +40,9 @@ function _M.getPackage()
3940 else
4041 ngx .var .ephemeralCacheStatus = ' HIT'
4142 end
43+ body = string.gsub (body , _M .hostPattern , base )
4244 ngx .header [" Content-Length" ] = # body
4345 ngx .print (body )
4446end
4547
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-
5548return _M
Original file line number Diff line number Diff line change @@ -63,14 +63,6 @@ http {
6363 proxy_buffers 32 1m ;
6464 # need to disable encoding in order to be able to process it locally
6565 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- }
7466 }
7567 location @fetch-tgz {
7668 internal ;
You can’t perform that action at this time.
0 commit comments