I’m using Express. How do I disable JSONP for specific routes?
I’m using Express. How do I disable JSONP for specific routes?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Looking at
res.json(), it appears there’s no explicit setting to disable JSONP per-route – it only checks the global app settingjsonp callback.You could simply clear the value of
req.query.callbackbefore callingres.json()in any route you don’t want to work via JSONP. As a middleware function:Now you can just do this: