首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >当我在Google中实现一个带有自定义域的sveltekit项目时,未能加载资源

当我在Google中实现一个带有自定义域的sveltekit项目时,未能加载资源
EN

Stack Overflow用户
提问于 2021-03-31 16:53:18
回答 1查看 1.4K关注 0票数 2

描述错误:我使用与节点适配器一起运行我的svelte工具包应用程序。它似乎适用于默认版本,但对于我的自定义域,它无法在slug.svelte路由中加载资源。

默认版本:

代码语言:javascript
运行
复制
https://youernes-22w6ta6irq-ew.a.run.app/yhoyquetoca
https://youernes-22w6ta6irq-ew.a.run.app/planes/UEVytEBG6rfcLrdqflD8TsjmCRn2_1611080173358

自定义域版本:

代码语言:javascript
运行
复制
https://youernes.com/yhoyquetoca
https://youernes.com/planes/UEVytEBG6rfcLrdqflD8TsjmCRn2_1602059251917

在自定义域版本中,虽然可以从脚本模块获取数据,但无法访问信息。

我使用节点适配器,这是我的以下配置:

代码语言:javascript
运行
复制
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“节点”、“构建/”

当我访问平面文件夹时,我会得到以下错误:

代码语言:javascript
运行
复制
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定制域来实现它。有人能帮我吗,甚至试过这个?

非常感谢大家。

EN

回答 1

Stack Overflow用户

发布于 2021-04-03 11:54:45

最后,我通过在google云运行上映射自定义域来解决这个问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66892055

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档