Having issues with Next JS dynamic routes resulting in a 404 Error. Initially attempted debugging by setting it up dynamically, then manually at http://localhost:3001/question/62e7b69ca560b1c81aa1a853 but still encountering the same issue. Tried toggling fallback between true and false without success even after exploring various online solutions.
Directory structure -> pages -> question -> [id] -> index.js
export const getStaticPaths = async () => {
try {
return {
paths: [
{
params: {
id: '62e7b69ca560b1c81aa1a853',
},
},
],
fallback: true,
};
} catch (err) {
return {
paths: [],
fallback: false,
};
}
};
export const getStaticProps = async ({ params }) => {
const res = await axios.get(
`http://localhost:3000/api/v1/q_a/getQAquestionById/${params.id}`
);
const data = await res.data.data.question;
return {
props: {
question: data,
},
revalidate: 1,
};
};