Skip to content

Commit

Permalink
manage cors
Browse files Browse the repository at this point in the history
  • Loading branch information
eerkaijun committed Jan 19, 2024
1 parent 3215c77 commit a7dda85
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
2 changes: 2 additions & 0 deletions paymaster/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
"@types/body-parser": "^1.19.2",
"@types/express": "^4.17.17",
"@types/node": "^20.5.7",
"@types/cors": "^2.8.17",
"axios": "^1.5.0",
"body-parser": "^1.20.2",
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"ethers": "^6.7.1",
"express": "^4.18.2",
Expand Down
33 changes: 29 additions & 4 deletions paymaster/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions paymaster/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import express, { Express, Request, Response } from 'express';
import bodyParser from 'body-parser';
import cors from 'cors';
import { sponsorTransaction, UserOperation } from './rpcMethods';

type JsonRpcRequestBody = {
Expand All @@ -13,6 +14,9 @@ const port = 3000;

app.use(bodyParser.json());

// Use cors middleware to enable CORS
app.use(cors({ origin: '*' }));

app.post('/', async(req: Request, res: Response) => {
const { id, method, params } = req.body as JsonRpcRequestBody;

Expand Down

0 comments on commit a7dda85

Please sign in to comment.