Nextjs redirect path has a redirection from HTTP to HTTPS

Viewed 27

Im running my nextjs (UI only) application on localhost http://localhost:3000/, this localhost has to connect to BE API (another hosted service) say https://test-api/api/graphql. This API is called from FE on path http://localhost:3000/api/graphql which connect to https://test-api/api/graphql with the help of nextjs rewrite function

    async rewrites() {
        const rewrites = [];

        rewrites.push({
            source: "/api/graphql",
            destination: "https://test-api/api/graphql",
        });

        return rewrites;
    },

Now looks like my BE api https://test-api/api/graphql is doing a force direct for path http://localhost:3000/api/graphql to https://localhost/api/graphql

And now since https://localhost/api/graphql is not existing, I'm unable to connect to the BE API. Any idea what can i do in nextjs config so that even if redirect is happening I'm still able to connect to my BE API

Facing this issue only on local environment, hosted nextjs application is not having this issue as it is already on https

enter image description here

0 Answers
Related