Error : encoded URI return an error on a nextjs app deployed with firebase

247 Views Asked by At

I have an nextjs app deployed on firebase. Each product that has a space encoded with %20 returns an error : An unexpected error occurred. It worked well on localhost but not anymore when I deploy. Do you know why?

api.js

export async function fetchAPI(path) {
  const requestUrl = getStrapiURL(path);
  const response = await fetch(requestUrl);
  const data = await response.json();
  return data;
}

export async function getProduct(name) {
  const products = await fetchAPI(`/books?name=${name}`);
  return products?.[0];
}

[name.js]

const paths = products.map(
    (product) => `/books/${encodeURIComponent(product.name)}`
  );
  return { paths, fallback: false };
}
0

There are 0 best solutions below