Skip to content

Commit e5ac164

Browse files
authored
enable cors
Adding the snippet so that the sample is in sync with the docs.
1 parent 0524fab commit e5ac164

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ const app = express();
3737
app.use(express.json());
3838

3939
//enable CORS (for testing only -remove in production/deployment)
40-
app.use(cors({
41-
origin: '*'
42-
}));
40+
app.use((req, res, next) => {
41+
res.header('Access-Control-Allow-Origin', '*');
42+
res.header('Access-Control-Allow-Headers', 'Authorization, Origin, X-Requested-With, Content-Type, Accept');
43+
next();
44+
});
4345

4446
app.use(morgan('dev'));
4547

0 commit comments

Comments
 (0)