Skip to content

Commit ac2bc68

Browse files
authored
Don't bork locally without Hydro (#16361)
* Add hydro.maySend() check * Return a 200 to differentiate * Add NODE_ENV check, move below validation
1 parent ba4410a commit ac2bc68

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

middleware/events.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,17 @@ const router = express.Router()
1111

1212
router.post('/', async (req, res, next) => {
1313
const fields = omit(req.body, '_csrf')
14+
1415
if (!ajv.validate(schema, fields)) {
1516
if (process.env.NODE_ENV === 'development') console.log(ajv.errorsText())
1617
return res.status(400).json({})
1718
}
19+
20+
// Don't depend on Hydro on local development
21+
if (process.env.NODE_ENV === 'development' && !req.hydro.maySend()) {
22+
return res.status(200).json({})
23+
}
24+
1825
try {
1926
const hydroRes = await req.hydro.publish(
2027
req.hydro.schemas[fields.type],

0 commit comments

Comments
 (0)