Код: Выделить всё
async function loadMDX(componentPath) {
try {
const { public: { docsBasePath } } = useRuntimeConfig();
console.log("Receved from nuxt: ", docsBasePath)
// 1) Fetch the raw text so vfile-matter can parse it
const res = await fetch(`/docs/${componentPath}`);
const text = await res.text();
// 2) Parse frontmatter from that text
const file = new VFile({ value: text });
matter(file);
docsStates.value.selectedDocMatter = file.data.matter
// 3) Now import the compiled MDX module (for rendering)
const module = await import(`${docsBasePath}/${componentPath}`);
mdxContent.value = wrapWithProvider(module.default);
} catch (error) {
console.error(error);
mdxContent.value = null;
}
}
// for developement
DOCS_BASE_PATH=/docs
//for production
< /code>
При разработке загрузка этих файлов MDX работает отлично, но при производстве при развертывании в Vercel я просто получаю эту ошибку < /p>
< strong> ошибка:
typeError: не удалось получить динамически импортированный модуль: https://vdocs-brown.vercel.app/docs/@v1 ... onents.mdx
< /p>
< /blockquote>
Почему мое приложение Nuxt не находит его, особенно из -за того, что оно перечислено в моих файлах Vercel Static с этим пути
Подробнее здесь: https://stackoverflow.com/questions/793 ... production