-2
`export default function reservations() {
  let [reservationStock, setReservationStock] = useState([]);

  useEffect(() => {
    fetch(url, {
      headers: new Headers({
        Authorization:
          "MyBasic Credentials",
          "Content-Type": "application/json",
      }),
    })
      .then((response) => response.json())
      .then((result) => setReservationStock(result));
  }, []);

My .env.local

LE_AUTH=MyBasic Credentials

I try different ways but none works.

Does anyone know how the right way?

Do not expose credentials

1 Answers1

0

You can use .env with prefix NEXT_PUBLIC as below :

  fetch(url, {
  headers: new Headers({
    Authorization:
      process.env.NEXT_PUBLIC_LE_AUTH,
      "Content-Type": "application/json",
  }),
  })
thanhyou00
  • 31
  • 4