Skip to content

Commit 9372652

Browse files
To make it easier to develop JS webapps against sparql-proxy we set the CORS header to '*'. There is a cors config to turn it off
1 parent adc40be commit 9372652

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/server.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const config = Object.freeze({
3838
port: Number(process.env.PORT || 3000),
3939
queryLogPath: process.env.QUERY_LOG_PATH,
4040
trustProxy: process.env.TRUST_PROXY || 'false',
41+
cors: process.env.ALLOW_CORS || 'true',
4142
});
4243

4344
const secret = `${config.adminUser}:${config.adminPassword}`;
@@ -184,6 +185,9 @@ async function executeQuery(req, res) {
184185

185186
res.header('Content-Type', result.contentType);
186187
res.header('X-Cache', result.cached ? 'hit' : 'miss');
188+
if (config.cors) {
189+
res.header('Access-Control-Allow-Origin', '*');
190+
}
187191
res.send(result.body);
188192
log({
189193
query,

0 commit comments

Comments
 (0)