参数“path”必须是字符串、Uint 8Array或不带空字节的URL,已在Heroku deploy上接收到“\x 00 @astro-page:astro/assets/endpoint/node”

nnt7mjpx  于 2024-01-08  发布在  其他
关注(0)|答案(1)|浏览(237)

我修改了我的Astro Web应用程序以使用SSR(Web应用程序是一个博客,所以我希望博客中的所有帖子都有动态路由)。
似乎该应用程序在我的本地PC上工作正常,但当我试图将其部署到heroku时,它失败了,并出现此错误-

  1. 10:09:58 PM [content] No content directory found. Skipping type generation.
  2. 10:09:58 PM [build] output target: server
  3. 10:09:58 PM [build] deploy adapter: @astrojs/node
  4. 10:09:58 PM [build] Collecting build info...
  5. 10:09:58 PM [build] Completed in 495ms.
  6. 10:09:58 PM [build] Building server entrypoints...
  7. [vite:load-fallback] Could not load @astro-page:astro/assets/endpoint/node (imported by @astrojs-ssr-virtual-entry): The argument 'path' must be a string, Uint8Array, or URL without null bytes. Received '\x00@astro-page:astro/assets/endpoint/node'
  8. error Could not load @astro-page:astro/assets/endpoint/node (imported by @astrojs-ssr-virtual-entry): The argument 'path' must be a string, Uint8Array, or URL without null bytes. Received '\x00@astro-page:astro/assets/endpoint/node'
  9. TypeError [PLUGIN_ERROR]: Could not load @astro-page:astro/assets/endpoint/node (imported by @astrojs-ssr-virtual-entry): The argument 'path' must be a string, Uint8Array, or URL without null bytes. Received '\x00@astro-page:astro/assets/endpoint/node'
  10. at open (node:internal/fs/promises:586:10)
  11. at Object.readFile (node:internal/fs/promises:1044:20)
  12. at Object.load (file:///tmp/build_73de6bf3/node_modules/vite/dist/node/chunks/dep-df561101.js:47019:28)
  13. at async PluginDriver.hookFirstAndGetPlugin (file:///tmp/build_73de6bf3/node_modules/rollup/dist/es/shared/node-entry.js:25439:28)
  14. at async file:///tmp/build_73de6bf3/node_modules/rollup/dist/es/shared/node-entry.js:24606:75
  15. at async Queue.work (file:///tmp/build_73de6bf3/node_modules/rollup/dist/es/shared/node-entry.js:25649:32)
  16. -----> Build failed

字符串
我已经按照指示安装了适配器,如下所示

  1. npm install @astrojs/node


在astro.config.mjs中,这是我的配置

  1. import { defineConfig } from 'astro/config';
  2. import vue from "@astrojs/vue";
  3. import node from "@astrojs/node";
  4. // https://astro.build/config
  5. export default defineConfig({
  6. integrations: [vue()],
  7. server: {
  8. host: '0.0.0.0',
  9. port: parseInt(process.env.PORT, 10) || 3000
  10. },
  11. output: 'server',
  12. adapter: node({
  13. mode: "middleware"
  14. })
  15. });


这是我的package.json文件

  1. {
  2. "name": "astrowebsite",
  3. "type": "module",
  4. "version": "0.0.1",
  5. "scripts": {
  6. "dev": "astro dev",
  7. "start": "astro dev",
  8. "build": "astro build",
  9. "preview": "astro preview",
  10. "astro": "astro"
  11. },
  12. "dependencies": {
  13. "@astrojs/node": "^6.0.4",
  14. "@astrojs/tailwind": "^5.0.0",
  15. "@astrojs/vue": "^3.0.0",
  16. "@caisy/rich-text-astro-renderer": "^1.0.2",
  17. "@popperjs/core": "^2.11.8",
  18. "@types/bootstrap": "^5.2.7",
  19. "@vueuse/core": "^10.4.1",
  20. "astro": "^3.1.3",
  21. "astro-bootstrap": "^0.6.1",
  22. "axios": "^1.5.1",
  23. "bootstrap": "^5.3.2",
  24. "mdb-vue-ui-kit": "^4.1.0",
  25. "portal-vue": "^3.0.0-beta.0",
  26. "vue": "^3.3.4",
  27. "vue-easy-lightbox": "^1.16.0",
  28. "vue-gallery": "^2.0.5",
  29. "vue-markdown": "^2.2.4"
  30. }
  31. }


这是我在应用程序中进行动态路由的方法

  1. const response = await fetch(
  2. "<My heroku url that I do the fetch from>"
  3. );
  4. const { data } = await response.json();
  5. const { slug } = Astro.params;
  6. const page = data.find((project) => project.attributes.title === slug);
  7. if (!page) return Astro.redirect("/404");
  8. const { id, attributes } = page;


Heroku提到的那些端点是什么?如何使用SSR连接到那个端点?Heroku服务器框架是nodejs,我不知道如何解决这个问题.我似乎找不到足够的文档,或者从错误中理解我应该做什么。
提前感谢!

nimxete2

nimxete21#

我把我的Astro SSR应用程序转移到Vercel,因为Heroku不支持SSR:-)

相关问题