Skip to content

Commit

Permalink
Merge pull request #13295 from storybookjs/13268-handle-json
Browse files Browse the repository at this point in the history
Core: Only apply `express.json()` middleware to /runtime-error route
  • Loading branch information
shilman committed Nov 26, 2020
2 parents 8f893e2 + c5d678f commit dcbe782
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/core/src/server/dev-server.ts
Expand Up @@ -281,10 +281,11 @@ const startManager = async ({
next();
});

router.post('/runtime-error', (request, response) => {
// Used to report back any client-side (runtime) errors
router.post('/runtime-error', express.json(), (request, response) => {
if (request.body?.error) {
logger.error('Runtime error! Check your browser console.');
logger.error(request.body.error.stack || request.body.message);
logger.error(request.body.error.stack || request.body.message || request.body);
if (request.body.origin === 'manager') clearManagerCache(options.cache);
}
response.sendStatus(200);
Expand Down Expand Up @@ -373,9 +374,6 @@ export async function storybookDevServer(options: any) {
options.extendServer(server);
}

// Used to report back any client-side (runtime) errors
app.use(express.json());

app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
Expand Down

0 comments on commit dcbe782

Please sign in to comment.