File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
packages/micro-analytics-cli/src Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -25,10 +25,12 @@ function realtimeHandler(req, res) {
2525}
2626
2727async function readMeta ( req ) {
28- if ( await text ( req ) ) {
28+ try {
2929 return ( await json ( req ) ) . meta ;
30+ } catch ( error ) {
31+ console . error ( 'Failed parsing meta' , error ) ;
32+ return null ;
3033 }
31- return null ;
3234}
3335
3436async function analyticsHandler ( req , res ) {
@@ -56,13 +58,16 @@ async function analyticsHandler(req, res) {
5658 if ( pathname . length <= 1 ) {
5759 throw createError ( 400 , 'Please include a path to a page.' ) ;
5860 }
61+
5962 if ( req . method === 'OPTIONS' ) {
6063 res . setHeader ( 'Access-Control-Allow-Headers' , 'content-type' ) ;
6164 return send ( res , 204 ) ;
6265 }
66+
6367 if ( req . method !== 'GET' && req . method !== 'POST' ) {
6468 throw createError ( 400 , 'Please make a GET or a POST request.' ) ;
6569 }
70+
6671 const shouldIncrement = String ( query . inc ) !== 'false' ;
6772 try {
6873 let meta ;
You can’t perform that action at this time.
0 commit comments