Skip to content

Commit

Permalink
Add CORS policy
Browse files Browse the repository at this point in the history
A basic CORS policy was added, to prevent CORS errors when making API requests from the Damus website.

Changelog-Added: Add CORS policy allowing requests from the Damus website
Signed-off-by: Daniel D’Aquino <[email protected]>
  • Loading branch information
danieldaquino authored and jb55 committed Jan 15, 2024
1 parent 17832b5 commit 1d0edbb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/router_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ const { create_account, get_account_info_payload, check_account } = require('./u
const handle_translate = require('./translate')
const verify_receipt = require('./app_store_receipt_verifier').verify_receipt
const bodyParser = require('body-parser')
const { required_nip98_auth, capture_raw_body } = require('./nip98_auth')
const cors = require('cors');
const { required_nip98_auth, capture_raw_body, optional_nip98_auth } = require('./nip98_auth')

function config_router(app) {
const router = app.router

router.use(bodyParser.json({ verify: capture_raw_body, type: 'application/json' }))
router.use(bodyParser.raw({ verify: capture_raw_body, type: 'application/octet-stream' }))
router.use(cors({ origin: ['https://damus.io', 'http://localhost:3000'] }))

router.use((req, res, next) => {
res.on('finish', () => {
Expand Down

0 comments on commit 1d0edbb

Please sign in to comment.