描述错误:我使用与节点适配器一起运行我的svelte工具包应用程序。它似乎适用于默认版本,但对于我的自定义域,它无法在slug.svelte路由中加载资源。
默认版本:
https://youernes-22w6ta6irq-ew.a.run.app/yhoyquetoca
https://youernes-22w6ta6irq-ew.a.run.app/planes/UEVytEBG6rfcLrdqflD8TsjmCRn2_1611080173358自定义域版本:
https://youernes.com/yhoyquetoca
https://youernes.com/planes/UEVytEBG6rfcLrdqflD8TsjmCRn2_1602059251917在自定义域版本中,虽然可以从脚本模块获取数据,但无法访问信息。
我使用节点适配器,这是我的以下配置:
const sveltePreprocess = require("svelte-preprocess");
const node = require('@sveltejs/adapter-node');
const pkg = require('./package.json');
/** @type {import('@sveltejs/kit').Config} */
module.exports = {
preprocess: [
sveltePreprocess({
defaults: {
style: "postcss",
},
postcss: true
}),
],
kit: {
hostHeader: 'X-Forwarded-Host',
// By default, `npm run build` will create a standard Node app.
// You can create optimized builds for different platforms by
// specifying a different adapter
adapter: node(),
// hydrate the <div id="svelte"> element in src/app.html
target: '#svelte',
vite: {
ssr: {
noExternal: Object.keys(pkg.dependencies || {})
}
}
}
};第一,我运行npm运行构建
第二我用码头
来自节点的
:12.17
WORKDIR /youernes
ENV PORT=8080
ENV HOST=0.0.0.0
收到。。
CMD“节点”、“构建/”
当我访问平面文件夹时,我会得到以下错误:
GET https://youernes.com/_app/pages/planes/[slug].svelte-098e0796.js net::ERR_ABORTED 404
GET https://youernes.com/_app/assets/pages/planes/[slug].svelte-377bb070.css net::ERR_ABORTED 404
Failed to fetch dynamically imported module: https://youernes.com/_app/pages/planes/[slug].svelte-098e0796.js
TypeError: Failed to fetch dynamically imported module: https://youernes.com/_app/pages/planes/[slug].svelte-098e0796.js如何重现这个问题以获得解决方案:您必须用节点适配器实现一个带有slug.svelte路由的svelte工具包项目,然后使用GoogleCloudRunwith定制域来实现它。有人能帮我吗,甚至试过这个?
非常感谢大家。
发布于 2021-04-03 11:54:45
最后,我通过在google云运行上映射自定义域来解决这个问题。
https://stackoverflow.com/questions/66892055
复制相似问题