mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 07:25:10 +00:00
CORS Enablement (#696)
After feedback from the community, this PR adds CORS support in, but as an option to enable. Along with warnings that the default wildcard origin might not be applicable in a production use case Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
This commit is contained in:
parent
0262d264d8
commit
99e7ae8536
3 changed files with 1207 additions and 3312 deletions
4504
asset-transfer-basic/rest-api-typescript/package-lock.json
generated
4504
asset-transfer-basic/rest-api-typescript/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -9,6 +9,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"bullmq": "^1.47.2",
|
||||
"cors": "^2.8.5",
|
||||
"dotenv": "^10.0.0",
|
||||
"env-var": "^7.0.1",
|
||||
"express": "^4.17.1",
|
||||
|
|
@ -24,9 +25,10 @@
|
|||
"source-map-support": "^0.5.19"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/cors": "^2.8.12",
|
||||
"@types/express": "^4.17.12",
|
||||
"@types/ioredis": "^4.26.4",
|
||||
"@types/jest": "^26.0.24",
|
||||
"@types/jest": "^27.4.1",
|
||||
"@types/node": "^15.14.7",
|
||||
"@types/passport": "^1.0.7",
|
||||
"@types/pino": "^6.3.8",
|
||||
|
|
@ -38,13 +40,13 @@
|
|||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-prettier": "^3.4.0",
|
||||
"ioredis-mock": "^5.6.0",
|
||||
"jest": "^27.0.6",
|
||||
"jest": "^27.5.1",
|
||||
"jest-mock-extended": "^2.0.2-beta2",
|
||||
"pino-pretty": "^5.0.2",
|
||||
"prettier": "^2.3.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"supertest": "^6.1.4",
|
||||
"ts-jest": "^27.0.4",
|
||||
"ts-jest": "^27.1.4",
|
||||
"ts-node": "^10.1.0",
|
||||
"typescript": "^4.3.5"
|
||||
},
|
||||
|
|
@ -64,4 +66,4 @@
|
|||
"author": "Hyperledger",
|
||||
"license": "Apache-2.0",
|
||||
"private": true
|
||||
}
|
||||
}
|
||||
|
|
@ -13,14 +13,13 @@ import { healthRouter } from './health.router';
|
|||
import { jobsRouter } from './jobs.router';
|
||||
import { logger } from './logger';
|
||||
import { transactionsRouter } from './transactions.router';
|
||||
import cors from 'cors';
|
||||
|
||||
const { BAD_REQUEST, INTERNAL_SERVER_ERROR, NOT_FOUND } = StatusCodes;
|
||||
|
||||
export const createServer = async (): Promise<Application> => {
|
||||
const app = express();
|
||||
|
||||
// Remember for production usage, to check any TLS or CORS requirements
|
||||
|
||||
app.use(
|
||||
pinoMiddleware({
|
||||
logger,
|
||||
|
|
@ -51,7 +50,7 @@ export const createServer = async (): Promise<Application> => {
|
|||
app.use(passport.initialize());
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
// TBC
|
||||
app.use(cors());
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
|
|
|
|||
Loading…
Reference in a new issue