Next.js: backend server path is defined in next.config.js rewrites() but it returns 404 error

1.3k Views Asked by At

This is the path I want to visit to:

export async function getServerSideProps() {
    const url = 'http://127.0.0.1:3000/api/auth/profile/';
    const resp = await axios.get(url, {withCredentials: true})
    const json = await resp.json()
    console.log(json)
    return {
        props: {}
    }
};

This is next.config.js:

module.exports = {
    async rewrites() {
        return [
          {
            source: '/api/auth/:path*',
            destination: 'http://127.0.0.1:8000/api/auth/:path*'
          },
        ]
    },
}

But it's returning this:

Server Error

Error [ERR_FR_TOO_MANY_REDIRECTS]: Maximum number of redirects exceeded

What should I do?

0

There are 0 best solutions below