【问题标题】:Nuxt Strapi Connection RefusedNuxt Strapi 连接被拒绝
【发布时间】:2023-02-06 14:39:07
【问题描述】:

我在 localhost:3000 上有一个 Nuxt 应用程序,在 localhost:1337 上有一个 Strapi 后端。 两者都可以单独正常工作(每个文件夹上的 npm run dev 都可以正常加载)。 我正在尝试将这两者与@nuxtjs/strapi 联系起来。

我在控制台上收到拒绝连接。

我究竟做错了什么?

Nuxt v2.15.8 Strapi v.4.4.3

nuxt.config.js

export default {
  server: {
    port: 3000
  },
  
  buildDir: '_nuxt',
  build: {
    publicPath: '_nuxt/dist/'
  },
  serverMiddleware: ['~/server-middleware/logger'],

  // Global page headers (https://go.nuxtjs.dev/config-head)
  
  // Global CSS (https://go.nuxtjs.dev/config-css)
  css: [
    '~assets/css/globalwd.css',
    '~assets/scss/styles.scss',
    '@fortawesome/fontawesome-free/css/all.css'

  ],

 
  // Auto import components (https://go.nuxtjs.dev/config-components)
  components: true,

  // Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
  buildModules: [
  ],

  // Modules (https://go.nuxtjs.dev/config-modules)
  modules: [
    // https://go.nuxtjs.dev/bootstrap
    '@nuxtjs/style-resources',
    '@nuxtjs/bulma', 
    '@nuxtjs/sitemap',
    '@nuxtjs/proxy',
    '@nuxtjs/axios',
    // '@nuxtjs/apollo',
    '@nuxtjs/strapi',
    
    
    
  ],
  styleResources: {
    scss: ['./assets/scss/*.scss']
  },
  // proxy: {
  //   '/api/strapi': {
  //     target: 'http://localhost:1337',
  //     pathRewrite: {
  //       '^/api/strapi': '/'
  //     }
  //   }
  // },    
  strapi: {
    // Options
    entities: ['forms'],
    url: '/api',
    // prefix: '/api',
    // version: 'v4',
    // cookie: {},
    // cookieName: 'strapi_jwt'
    url: 'http://localhost:1337'
  },
 
  build: {
    postcss: {
      preset: {
        features: {
          customProperties: false
        }
      }
    },
  }
}

【问题讨论】:

  • 你好,介意分享你的 Nuxt 配置文件吗?
  • 我用配置文件@kissu 编辑了问题

标签: nuxt.js strapi nuxt-strapi


【解决方案1】:

我无法使用我使用的 nuxt 和 strapi 版本解决此问题,但我确实安装了带有 strapi4 的 nuxt3,这在新项目中起到了作用。 我关注了this link,成功了。

我创建了一个新项目,然后有一个后端文件夹,然后是一个前端文件夹。 我在后端文件夹中安装了 Strapi4,在前端文件夹中安装了 Nuxt3,并且按照我发布的链接可以无缝连接。

【讨论】:

    猜你喜欢
    • 2022-01-10
    • 2017-08-08
    • 1970-01-01
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 2018-08-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多