I facing compiling /404 (client and server)... Error in Terminal
Unanswered
Abyssinian posted this in #help-forum
AbyssinianOP
This is my home page I fetch data like the below code.
index.jsx -----------------
export async function getServerSideProps() {
// Fetch data from an API or perform any async operations
const res = await fetch('https://cms.tropicalhomesltd.com/api/get-req-data/sections?type=slug&value=home&get_section=yes&image=yes&post=yes');
const data = await res.json();
// Pass fetched data as props to the component
return {
props: {
data,
},
};
}
_app.js -------------------------------------------
const router = useRouter()
wrapper.getInitialAppProps(
(store) =>
async ({Component, ctx}) => {
// Wait for all page actions to dispatch
const pageProps = {
...(Component.getInitialProps
? await Component.getInitialProps({...ctx, store})
: {}),
};
// 2.1 Stop if on server
if ((ctx.req) && Component.getInitialProps) {
// store.dispatch(END)
// used in hydration reducer
store.dispatch({type: SET_IS_SERVER})
}
// getServerSideProps is used
const isServer = !ctx.req?.url?.startsWith("/_next");
if (isServer && !Component.getInitialProps) {
// used in hydration reducer
store.dispatch({type: SET_IS_SERVER});
}
// 3. Return props
return {
pageProps,
};
}
);
how can I solve this error
index.jsx -----------------
export async function getServerSideProps() {
// Fetch data from an API or perform any async operations
const res = await fetch('https://cms.tropicalhomesltd.com/api/get-req-data/sections?type=slug&value=home&get_section=yes&image=yes&post=yes');
const data = await res.json();
// Pass fetched data as props to the component
return {
props: {
data,
},
};
}
_app.js -------------------------------------------
const router = useRouter()
wrapper.getInitialAppProps(
(store) =>
async ({Component, ctx}) => {
// Wait for all page actions to dispatch
const pageProps = {
...(Component.getInitialProps
? await Component.getInitialProps({...ctx, store})
: {}),
};
// 2.1 Stop if on server
if ((ctx.req) && Component.getInitialProps) {
// store.dispatch(END)
// used in hydration reducer
store.dispatch({type: SET_IS_SERVER})
}
// getServerSideProps is used
const isServer = !ctx.req?.url?.startsWith("/_next");
if (isServer && !Component.getInitialProps) {
// used in hydration reducer
store.dispatch({type: SET_IS_SERVER});
}
// 3. Return props
return {
pageProps,
};
}
);
how can I solve this error
2 Replies
Asian paper wasp
And the question is????
You try to visit
You try to visit
/ but end up being redirected to 404?AbyssinianOP
No. When I switch / to /about page there /404 show in my terminal.\