Skip to content

Commit

Permalink
fix: restore cors header injection from #4171
Browse files Browse the repository at this point in the history
  • Loading branch information
calebcartwright committed May 21, 2020
1 parent 8ceb4f2 commit acbefa9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,12 @@ class Server {
const { apiProvider: githubApiProvider } = this.githubConstellation
suggest.setRoutes(allowedOrigin, githubApiProvider, camp)

// https://github.com/badges/shields/issues/3273
camp.handle((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*')
next()
})

this.registerErrorHandlers()
this.registerRedirects()
this.registerServices()
Expand Down
6 changes: 6 additions & 0 deletions core/server/server.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,10 @@ describe('The server', function () {
})
})
})

it('should return cors header for the request', async function() {
const { statusCode, headers } = await got(`${baseUrl}npm/v/express.svg`)
expect(statusCode).to.equal(200)
expect(headers['access-control-allow-origin']).to.equal('*')
})
})

0 comments on commit acbefa9

Please sign in to comment.