Express 为什么可以';我是否在nuxt的服务器中间件中使用参数创建路由?

Express 为什么可以';我是否在nuxt的服务器中间件中使用参数创建路由?,express,nuxt.js,middleware,nuxt.config.js,Express,Nuxt.js,Middleware,Nuxt.config.js,我在配置serverMIddleware属性时遇到问题,一切都正常工作,但除了初始路由之外,我无法创建任何其他路由 Mi numxt.config.js文件: export default { // Target: https://go.nuxtjs.dev/config-target target: 'static', ssr: true, // Global page headers: https://go.nuxtjs.dev/confi

我在配置serverMIddleware属性时遇到问题,一切都正常工作,但除了初始路由之外,我无法创建任何其他路由

Mi numxt.config.js文件:

  export default {
      // Target: https://go.nuxtjs.dev/config-target
      target: 'static',
      ssr: true,
      // Global page headers: https://go.nuxtjs.dev/config-head,
      modules: [
        '@nuxtjs/axios',
        '@nuxtjs/auth-next',
        // '~/modules/api/index.js'
      ],
      serverMiddleware:[
        { path: '/api', handler: '~/api/index.js'},
      ],
      axios: {
        baseURL: 'http://localhost:3000/',
      },
      head: {
        title: 'Encontrar Hogar',
        htmlAttrs: {
          lang: 'en'
        },
        meta: [
          { charset: 'utf-8' },
          { name: 'viewport', content: 'width=device-width, initial-scale=1' },
          { hid: 'description', name: 'description', content: 'Encontra tu nuevo hogar en chacabuco. Todas las propiedades e inmuebles de Chacabuco en un mismo lugar' },
        ],
        link: [
          { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
          { rel: 'stylesheet', href: '/normalize.css' },
          { rel: 'stylesheet', href: "https://unpkg.com/swiper/swiper-bundle.min.css" }
        ],
        script: [
          { src: "https://kit.fontawesome.com/57d52ad1ee.js", crossorigin: "anonymous" },
        ]
      },
      loading: {
        color: 'black',
        height: '8px',
        continuous: true
      },
      css: [
        '@/assets/css/index.css'
      ],
      auth: {
        cookie:{
          options:{
            secure: true
          }
        },
        strategies: {
          local: {
            token: {
              property: 'token'
            },
            user: {
              property: 'user'
            },
            endpoints: {
              login: { url: '/api/usuarios/login', method: 'post', propertyName: 'data' },
              user: { url: '/api/usuarios/mi-perfil', method: 'get', propertyName: 'data' },
              logout: false
            }
          }
        }
      },
      // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
      plugins: ['~/plugins/swiper.js'],
      // Auto import components: https://go.nuxtjs.dev/config-components
      components: true
    }
/api/index.js文件:

const bodyParser = require('body-parser')
const app = require('express')()

app.get('/api/:id?', (req, res) => res.send('hello'))

module.exports = app
如果我尝试创建像下面我将留下的端点一样的端点,当通过浏览器或邮递员发出get请求时,我得到的唯一结果是404 not found响应,我不明白我配置的错误是什么

app.get('/api/products', (req, res) => res.send('products'))
你打电话了吗http://localhost:3000/api/youridhere ?

根据您的配置和ServeMiddle软件,您的链接应该是http://localhost:3000/api/api/youridhere