Skip to content

Commit

Permalink
configure cors
Browse files Browse the repository at this point in the history
  • Loading branch information
smalho01 committed Jan 13, 2025
1 parent 4c6a683 commit 65a237f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cors from 'cors';
import cors, { CorsOptions } from 'cors';
import bodyParser from 'body-parser';
import container from './lib/winston';
import morgan from 'morgan';
Expand All @@ -25,7 +25,7 @@ const logger = container.get('application');
const initialize = (config: Config): REMSIntermediary => {
//const logLevel = _.get(config, 'logging.level');
return new REMSIntermediary(config.fhirServerConfig)
.configureMiddleware()
.configureMiddleware(config.fhirServerConfig.server.corsOptions)
.configureSession()
.configureHelmet()
.configurePassport()
Expand Down Expand Up @@ -71,16 +71,16 @@ class REMSIntermediary extends Server {
* @method configureMiddleware
* @description Enable all the standard middleware
*/
configureMiddleware(): REMSIntermediary {
configureMiddleware(corsOptions: CorsOptions): REMSIntermediary {
super.configureMiddleware();
this.app.set('showStackError', true);
this.app.set('jsonp callback', true);
this.app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
this.app.use(bodyParser.json({ limit: '50mb' }));

this.app.use(cors());
this.app.use(cookieParser());
this.app.options('*', cors());
this.app.use(cors(corsOptions));
this.app.options('*', cors(corsOptions));

return this;
}
Expand Down

0 comments on commit 65a237f

Please sign in to comment.