Skip to content

Commit

Permalink
added cors header to readable resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Forberg committed Feb 1, 2024
1 parent da9e6fc commit c8294d8
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
3 changes: 2 additions & 1 deletion public/js/page-controller/group-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const DataIdCreator = require("../publish/dataid-creator");
const QueryBuilder = require("../query-builder/query-builder");
const QueryNode = require("../query-builder/query-node");
const QueryTemplates = require("../query-builder/query-templates");
const DatabusConstants = require("../utils/databus-constants");
const DatabusUtils = require("../utils/databus-utils");
const DatabusWebappUtils = require("../utils/databus-webapp-utils");
const TabNavigation = require("../utils/tab-navigation");
Expand Down Expand Up @@ -143,7 +144,7 @@ function GroupPageController($scope, $http, $sce, $interval, $location, collecti
$scope.fileSelector.config.columns.push({ field: 'compression', label: 'Compression', width: '6%' });

$scope.groupNode = new QueryNode($scope.group.uri, 'databus:group');
$scope.groupNode.setFacet('http://purl.org/dc/terms/hasVersion', '$latest', true);
$scope.groupNode.setFacet('http://purl.org/dc/terms/hasVersion', DatabusConstants.FACET_LATEST_VERSION_VALUE, true);

$scope.onFacetSettingsChanged = function () {
$scope.fileSelector.query = QueryBuilder.build({
Expand Down
2 changes: 1 addition & 1 deletion server/app/api/module.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const getLinkedData = require('../common/get-linked-data.js');
const ServerUtils = require('../common/utils/server-utils.js');
var cors = require('cors');

Expand All @@ -18,5 +19,4 @@ module.exports = function (router, protector, locals, webdav) {
});



}
3 changes: 2 additions & 1 deletion server/app/api/routes/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const Constants = require('../../common/constants');
const UriUtils = require('../../common/utils/uri-utils');
const DatabusConstants = require('../../../../public/js/utils/databus-constants');
const publishAccount = require('../lib/publish-account');
var cors = require('cors');

module.exports = function (router, protector) {

Expand Down Expand Up @@ -403,7 +404,7 @@ module.exports = function (router, protector) {
});

/* GET an account. */
router.get('/:account', ServerUtils.NOT_HTML_ACCEPTED, async function (req, res, next) {
router.get('/:account', ServerUtils.NOT_HTML_ACCEPTED, cors(), async function (req, res, next) {

if (req.params.account.length < 4) {
next('route');
Expand Down
3 changes: 2 additions & 1 deletion server/app/api/routes/artifact.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const publishArtifact = require('../lib/publish-artifact');
const defaultContext = require('../../common/res/context.jsonld');
const getLinkedData = require("../../common/get-linked-data");
const jsonld = require('jsonld');
var cors = require('cors');

const sparql = require("../../common/queries/sparql");

Expand Down Expand Up @@ -66,7 +67,7 @@ module.exports = function (router, protector) {
}
});

router.get('/:account/:group/:artifact', ServerUtils.NOT_HTML_ACCEPTED, async function (req, res, next) {
router.get('/:account/:group/:artifact', ServerUtils.NOT_HTML_ACCEPTED, cors(), async function (req, res, next) {

if (req.params.account.length < 4) {
next('route');
Expand Down
5 changes: 3 additions & 2 deletions server/app/api/routes/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var defaultContext = require('./../../common/res/context.jsonld');
const DatabusConstants = require('../../../../public/js/utils/databus-constants');
const DatabusUtils = require('../../../../public/js/utils/databus-utils');
const DatabusMessage = require('../../common/databus-message');
var cors = require('cors');

module.exports = function (router, protector) {

Expand Down Expand Up @@ -185,7 +186,7 @@ module.exports = function (router, protector) {
}
});

router.get('/:account/collections/:collection', ServerUtils.SPARQL_ACCEPTED, async function (req, res, next) {
router.get('/:account/collections/:collection', ServerUtils.SPARQL_ACCEPTED, cors(), async function (req, res, next) {

sparql.collections.getCollectionQuery(req.params.account, req.params.collection).then(function (result) {
if (result != null) {
Expand All @@ -199,7 +200,7 @@ module.exports = function (router, protector) {
});
});

router.get('/:account/collections/:collection', ServerUtils.NOT_HTML_ACCEPTED, function (req, res, next) {
router.get('/:account/collections/:collection', ServerUtils.NOT_HTML_ACCEPTED, cors(), function (req, res, next) {

if (req.params.account.length < 4) {
next('route');
Expand Down
3 changes: 2 additions & 1 deletion server/app/api/routes/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const publishGroup = require('../lib/publish-group');
const jsonld = require('jsonld');
const getLinkedData = require("../../common/get-linked-data");
const defaultContext = require('../../common/res/context.jsonld');
var cors = require('cors');

const sparql = require("../../common/queries/sparql");

Expand Down Expand Up @@ -57,7 +58,7 @@ module.exports = function (router, protector) {
}
});

router.get('/:account/:group', ServerUtils.NOT_HTML_ACCEPTED, async function (req, res, next) {
router.get('/:account/:group', ServerUtils.NOT_HTML_ACCEPTED, cors(), async function (req, res, next) {

if (req.params.account.length < 4) {
next('route');
Expand Down
4 changes: 3 additions & 1 deletion server/app/api/routes/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const getLinkedData = require('../../common/get-linked-data.js');
const DatabusLogger = require('../../common/databus-logger.js');
const JsonldUtils = require('../../../../public/js/utils/jsonld-utils.js');
const jsonld = require('jsonld');
var cors = require('cors');


module.exports = function (router, protector) {

Expand Down Expand Up @@ -58,7 +60,7 @@ module.exports = function (router, protector) {
}
});

router.get('/:account/:group/:artifact/:version', ServerUtils.NOT_HTML_ACCEPTED, async function (req, res, next) {
router.get('/:account/:group/:artifact/:version', ServerUtils.NOT_HTML_ACCEPTED, cors(), async function (req, res, next) {

if (req.params.account.length < 4) {
next('route');
Expand Down

0 comments on commit c8294d8

Please sign in to comment.