Skip to content

Commit b284fa7

Browse files
author
Andrei
committed
Merge pull request nodeSolidServer#135 from nicola/onlyGet
Only allow GET on proxy
2 parents 655648f + b2694dc commit b284fa7

2 files changed

Lines changed: 24 additions & 12 deletions

File tree

index.js

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,27 @@ function createServer(argv) {
131131

132132
function proxy (app, path) {
133133
debug.settings('XSS Proxy listening to ' + path);
134-
app.get(path, corsSettings, function (req, res) {
135-
debug.settings('originalUrl: ' + req.originalUrl);
136-
var uri = req.query.uri;
137-
if (!uri) {
138-
return res
139-
.status(400)
140-
.send("Proxy has no uri param ");
141-
}
142-
143-
debug.settings('Proxy destination URI: ' + uri);
144-
request.get(uri).pipe(res);
145-
});
134+
app.get(
135+
path,
136+
cors({
137+
methods: ['GET'],
138+
exposedHeaders: 'User, Location, Link, Vary, Last-Modified, Content-Length',
139+
credentials: true,
140+
maxAge: 1728000,
141+
origin: true
142+
}),
143+
function (req, res) {
144+
debug.settings('originalUrl: ' + req.originalUrl);
145+
var uri = req.query.uri;
146+
if (!uri) {
147+
return res
148+
.status(400)
149+
.send("Proxy has no uri param ");
150+
}
151+
152+
debug.settings('Proxy destination URI: ' + uri);
153+
request.get(uri).pipe(res);
154+
});
146155
}
147156

148157
function routes () {

test/params.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ describe('LDNODE params', function () {
2929
it('should also work on /proxy/ ?uri', function(done) {
3030
nock('https://amazingwebsite.tld').get('/').reply(200);
3131
server.get('/proxy/?uri=https://amazingwebsite.tld/')
32+
.expect(function (a) {
33+
assert.equal(a.header['link'], null)
34+
})
3235
.expect(200, done);
3336
});
3437

0 commit comments

Comments
 (0)