Skip to content

Commit

Permalink
Merge pull request #1434 from input-output-hk/cors-headers
Browse files Browse the repository at this point in the history
Add CORS headers to API.Server
  • Loading branch information
locallycompact committed May 14, 2024
2 parents 6427e5c + 6f47a3c commit cf535c7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ changes.
- Add `GET /snapshot/utxo` API endpoint to query confirmed UTxO set on demand.
- Always responds with the last confirmed UTxO

- Set [CORS](https://fetch.spec.whatwg.org/#http-cors-protocol) headers on `hydra-node` API to allow requests from any origin `*`.

- _DEPRECATED_ the `GetUTxO` client input and `GetUTxOResponse` server output. Use `GET /snapshot/utxo` instead.

- `hydra-node` logs will now report `NetworkEvents` to distinguish between `ConnectivityEvent`s and `ReceivedMessage`s on the network.
Expand Down
1 change: 1 addition & 0 deletions hydra-node/hydra-node.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ library
, unliftio
, vector
, wai
, wai-cors
, wai-websockets
, warp
, websockets
Expand Down
6 changes: 4 additions & 2 deletions hydra-node/src/Hydra/API/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import Network.Wai.Handler.Warp (
setPort,
)
import Network.Wai.Handler.WebSockets (websocketsOr)
import Network.Wai.Middleware.Cors (simpleCors)
import Network.WebSockets (
defaultConnectionOptions,
)
Expand Down Expand Up @@ -93,8 +94,9 @@ withAPIServer host port party PersistenceIncremental{loadAll, append} tracer cha
race_
( do
traceWith tracer (APIServerStarted port)
runSettings serverSettings $
websocketsOr
runSettings serverSettings
. simpleCors
$ websocketsOr
defaultConnectionOptions
(wsApp party tracer history callback headStatusP snapshotUtxoP responseChannel)
(httpApp tracer chain pparams (atomically $ getLatest headIdP) (atomically $ getLatest snapshotUtxoP))
Expand Down

0 comments on commit cf535c7

Please sign in to comment.