Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/407.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 错误:编码URI在使用firebase部署的nextjs应用程序上返回错误_Javascript_Firebase_Next.js_Uri_Encodeuricomponent - Fatal编程技术网

Javascript 错误:编码URI在使用firebase部署的nextjs应用程序上返回错误

Javascript 错误:编码URI在使用firebase部署的nextjs应用程序上返回错误,javascript,firebase,next.js,uri,encodeuricomponent,Javascript,Firebase,Next.js,Uri,Encodeuricomponent,我在firebase上部署了一个nextjs应用程序。每个使用%20编码的空格的产品都会返回一个错误:发生意外错误。 它在localhost上运行良好,但在部署时不再有效。 你知道为什么吗 api.js export async function fetchAPI(path) { const requestUrl = getStrapiURL(path); const response = await fetch(requestUrl); const data = await res

我在firebase上部署了一个nextjs应用程序。每个使用%20编码的空格的产品都会返回一个错误:发生意外错误。 它在localhost上运行良好,但在部署时不再有效。 你知道为什么吗

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 };
}

错误到底发生在什么时候?您可以添加错误和错误堆栈吗?我通过从[name].js中删除encodeURIComponent并使用中的方法从页面中找到此方法。对不起,这是一个棘手的解释。但是,我没有找到方法将%20替换为一个更干净的URL