Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: setup CORS to allow all origins #7

Closed
wants to merge 1 commit into from
Closed
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: 2 additions & 0 deletions lib/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ export const today = () => getDayAsISOString(new Date())
* @param {(import('pg').Pool, import('./typings').Filter) => Promise<object[]>} fetchStatsFn
*/
const getStatsWithFilterAndCaching = async (pathname, searchParams, res, pgPool, fetchStatsFn) => {
res.setHeader('access-control-allow-origin', '*')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe browsers disallow *, and we need to return a hostname instead. I propose to ditch this feature until we can do it proper, with tests etc

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC the docs in MDN, * is allowed only for requests with no credentials. I think we should be fine here.

I propose to ditch this feature until we can do it proper, with tests etc

Agreed.


let from = searchParams.get('from')
let to = searchParams.get('to')
let shouldRedirect = false
Expand Down