-1

I am having issues passing my environment variables as the url and headers for my axios patch request

const axios = require("axios");

export const  handleSubmit = async (formValue, uniquePageName) => {

await axios
  .patch(process.env.INTERNAL_RETAILER_CONFIG_UPDATE, formValue, {
    headers: {
        "Access-Control-Allow-Origin":process.env.INTERNAL_RETAILER_CONFIG_UPDATE,
        "x-auth-token":process.env.INTERNAL_TOKEN,
        retailername: uniquePageName,
        "Content-Type": "application/json",
    },
  })
  .then((res) => {
    return res.data;
  })
  .catch((error) => {
    console.log(error);
  });
};

I have moved this function inside the api folder and I am calling it on my submit button for on the form. I have attached the error on the console.

enter image description here

RMP1992
  • 55
  • 1
  • 1
  • 9
  • In Next.js, you have to add the `NEXT_PUBLIC_` prefix to environment variables to expose them to the browser. See [Environment variables not working (Next.JS 9.4.4)](https://stackoverflow.com/questions/62386582/environment-variables-not-working-next-js-9-4-4) and https://nextjs.org/docs/basic-features/environment-variables#exposing-environment-variables-to-the-browser. – juliomalves Aug 17 '22 at 18:23

1 Answers1

0

reqiure is not supported in browsers

use import axios from 'axios'