Hello. I have a getServerSideProps function and would like to verify the query to avoid security vulnerabilities and return a 404 page:
interface QueryType { id: string;}export const getServerSideProps = async ({ query }) => { // check query matches QueryType and return 404 page (return { notFound: true }) otherwise // ... use id to query from db and return}
interface QueryType { id: string;}export const getServerSideProps = async ({ query }) => { // check query matches QueryType and return 404 page (return { notFound: true }) otherwise // ... use id to query from db and return}
I've tried validating query with a zod schema, but that doesn't seem to let TS know that query has the type QueryType. How do i verify this in a way which works well for TS?