Skip to content
This repository was archived by the owner on Jun 13, 2022. It is now read-only.

feat: adding corsOptions config variable for CORS middleware in app.js #429

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@statusfy/core/server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = async function createApp(
);
}

app.use(cors());
app.use(!siteConfig.corsOptions ? cors() : cors(siteConfig.corsOptions));
// parse application/json
app.use(bodyParser.json());
app.use(language);
Expand Down
5 changes: 5 additions & 0 deletions packages/docs/src/guide/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ module.exports = {
title: 'Title',
description: 'Description',
baseUrl: 'https://demo.statusfy.co',
corsOptions: {
origin: '*'
},
analytics: {
ga: 'UA-XXXXXXXXX-Y',
},
Expand Down Expand Up @@ -89,3 +92,5 @@ module.exports = {
}
}
```

The `corsOptions` setting is optional and allows you to set CORS headers for custom routes if you ever need to use the Statusfy API. The above example just adds a wildcard, so all IPs can be used to access the API. For more information on setting up the correct CORS options, check out Express' official documentation [here](https://expressjs.com/en/resources/middleware/cors.html).