0

I have a dynamic product page at this address.

pages/product/_id/_slug/index.vue

My page is very dynamic and the product enters this page at any time.

This url works properly in dev. but after generate i cant see this page and i have error 404 in apache2.

my build and generate log.

> store-v1@1.0.0 build C:\nuxt\store-v1
> nuxt build

i [HPM] Proxy created: /api/  -> http://192.168.114.21:3000                                                                                                                                                                   19:29:32
i [HPM] Proxy rewrite rule created: "^/api/" ~> ""                                                                                                                                                                            19:29:32
i Production build                                                                                                                                                                                                            19:29:34
i Bundling only for client side                                                                                                                                                                                               19:29:34
i Target: static                                                                                                                                                                                                              19:29:34
i Using components loader to optimize imports                                                                                                                                                                                 19:29:34
i Discovered Components: .nuxt/components/readme.md                                                                                                                                                                           19:29:34
√ Builder initialized                                                                                                                                                                                                         19:29:34
√ Nuxt files generated                                                                                                                                                                                                        19:29:34

√ Client
  Compiled successfully in 53.18s


Hash: c58ad7824b9056285ab0
Version: webpack 4.46.0
Time: 53186ms
Built at: 1400 ├F3: 06┤ 19:30:29
                         Asset       Size     Chunks                                Chunk Names
../server/client.manifest.json   25.5 KiB             [emitted]
                    08a53f7.js   18.3 KiB          4  [emitted] [immutable]         components/card-post-grid-style
                    0923520.js   10.8 KiB         21  [emitted] [immutable]         pages/users/login/confirm
                    0f7d147.js   16.9 KiB     24, 15  [emitted] [immutable]         pages/users/profile
                    14aa143.js   9.24 KiB          8  [emitted] [immutable]         components/forms-edit-one-text-field
                    216da84.js   76.6 KiB          1  [emitted] [immutable]         app
                    2921435.js   7.04 KiB         20  [emitted] [immutable]         pages/products/detail/_id/_slug/index
                    345b1ea.js  282 bytes         16  [emitted] [immutable]         pages/cart
                    369fb90.js   20.4 KiB          0  [emitted] [immutable]         vendors/components/card-product/components/grid-card-product/pages/index/pages/products/_slug/index
                    5758cd8.js   9.54 KiB         10  [emitted] [immutable]         components/forms-edit-two-text-field
                    58c2515.js   29.4 KiB         30  [emitted] [immutable]         vendors/pages/users/profile
                    5b2b4ea.js   17.2 KiB          9  [emitted] [immutable]         components/forms-edit-one-textarea
                    5b35b8b.js   8.83 KiB       7, 6  [emitted] [immutable]         components/card-product-related-l-list
                    60a6c8b.js      7 KiB          6  [emitted] [immutable]         components/card-product-related
                    6e8bf48.js   7.61 KiB      13, 3  [emitted] [immutable]         components/list-card-posts
                    74a7e6d.js  725 bytes         23  [emitted] [immutable]         pages/users/logout
                    7d94924.js     19 KiB      11, 4  [emitted] [immutable]         components/grid-card-post
                    8479af8.js     11 KiB         22  [emitted] [immutable]         pages/users/login/register
                    8ba8afb.js   1.47 KiB         15  [emitted] [immutable]         components/objects-info-with-title
                    9126cb4.js   2.52 KiB          5  [emitted] [immutable]         components/card-product
                    953d3cd.js     28 KiB         28  [emitted] [immutable]         vendors/pages/products/_slug/index
                    99f201d.js   6.83 KiB          3  [emitted] [immutable]         components/card-post
                    9a0dfe6.js   2.62 KiB         26  [emitted] [immutable]         runtime
                      LICENSES  468 bytes             [emitted]
                    a221654.js  644 bytes         18  [emitted] [immutable]         pages/inspire
                    a3577d8.js  285 bytes         25  [emitted] [immutable]         pages/users/register/confirm
                    a7d9faa.js   21.4 KiB         29  [emitted] [immutable]         vendors/pages/products/detail/_id/_slug/index
                    a864bac.js    584 KiB         27  [emitted] [immutable]  [big]  vendors/app
                    ab5bec8.js  554 bytes         14  [emitted] [immutable]         components/list-cart-mini
                    c12f815.js   5.31 KiB  19, 5, 12  [emitted] [immutable]         pages/products/_slug/index
                    c142fe7.js    239 KiB          2  [emitted] [immutable]         commons/app
                    dea0503.js   9.38 KiB  17, 5, 12  [emitted] [immutable]         pages/index
       fonts/Tanha.153f40c.ttf   78.1 KiB             [emitted] [immutable]
       fonts/Vazir.83fea74.ttf   82.6 KiB             [emitted] [immutable]
       fonts/Yekan.f6a0838.ttf   65.7 KiB             [emitted] [immutable]
 + 1 hidden asset
Entrypoint app = 9a0dfe6.js c142fe7.js a864bac.js 216da84.js

WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
  a864bac.js (584 KiB)
i Ready to run nuxt generate                                                                                                                                                                                                  19:30:29
PS C:\nuxt\store-v1> npm run generate

> store-v1@1.0.0 generate C:\nuxt\store-v1
> nuxt generate

i Production build                                                                                                                                                                                                            19:30:41
i Bundling only for client side                                                                                                                                                                                               19:30:41
i Target: static                                                                                                                                                                                                              19:30:41
i Using components loader to optimize imports                                                                                                                                                                                 19:30:41
i Discovered Components: node_modules/.cache/nuxt/components/readme.md                                                                                                                                                        19:30:41
√ Builder initialized                                                                                                                                                                                                         19:30:41
√ Nuxt files generated                                                                                                                                                                                                        19:30:41

√ Client
  Compiled successfully in 59.25s


Hash: b532489d51ed894a0b78
Version: webpack 4.46.0
Time: 59249ms
Built at: 1400 ├F3: 06┤ 19:31:42
                         Asset       Size     Chunks                                Chunk Names
../server/client.manifest.json   24.7 KiB             [emitted]
                    1237af2.js   10.8 KiB         21  [emitted] [immutable]         pages/users/login/confirm
                    2b7ebc0.js   16.9 KiB     24, 15  [emitted] [immutable]         pages/users/profile
                    2c9e037.js     19 KiB      11, 4  [emitted] [immutable]         components/grid-card-post
                    30ded9a.js  554 bytes         14  [emitted] [immutable]         components/list-cart-mini
                    4739bd9.js   8.83 KiB       7, 6  [emitted] [immutable]         components/card-product-related-l-list
                    4815d83.js    637 KiB         27  [emitted] [immutable]  [big]  vendors/app
                    49359ee.js   1.47 KiB         15  [emitted] [immutable]         components/objects-info-with-title
                    4c9a568.js   21.4 KiB         29  [emitted] [immutable]         vendors/pages/products/detail/_id/_slug/index
                    5245c21.js  725 bytes         23  [emitted] [immutable]         pages/users/logout
                    548a6d2.js   29.4 KiB         30  [emitted] [immutable]         vendors/pages/users/profile
                    55a8415.js   5.31 KiB  19, 5, 12  [emitted] [immutable]         pages/products/_slug/index
                    65e69cb.js   18.3 KiB          4  [emitted] [immutable]         components/card-post-grid-style
                    6cb80c8.js   3.13 KiB      12, 5  [emitted] [immutable]         components/grid-card-product
                    754e2f0.js   9.24 KiB          8  [emitted] [immutable]         components/forms-edit-one-text-field
                    7687891.js     11 KiB         22  [emitted] [immutable]         pages/users/login/register
                    76c9cbc.js   7.04 KiB         20  [emitted] [immutable]         pages/products/detail/_id/_slug/index
                    7c29d72.js  282 bytes         16  [emitted] [immutable]         pages/cart
                    818ddac.js   6.83 KiB          3  [emitted] [immutable]         components/card-post
                    8ffff0f.js   17.2 KiB          9  [emitted] [immutable]         components/forms-edit-one-textarea
                    907b2be.js   2.62 KiB         26  [emitted] [immutable]         runtime
                    9288bcb.js   9.54 KiB         10  [emitted] [immutable]         components/forms-edit-two-text-field
                    936c232.js   20.4 KiB          0  [emitted] [immutable]         vendors/components/card-product/components/grid-card-product/pages/index/pages/products/_slug/index
                    94b3b26.js    239 KiB          2  [emitted] [immutable]         commons/app
                    965b1bb.js      7 KiB          6  [emitted] [immutable]         components/card-product-related
                    9f4be0e.js     28 KiB         28  [emitted] [immutable]         vendors/pages/products/_slug/index
                      LICENSES  468 bytes             [emitted]
                    ac266d2.js   23.3 KiB          1  [emitted] [immutable]         app
                    ae09b12.js   2.52 KiB          5  [emitted] [immutable]         components/card-product
                    b32919a.js   9.38 KiB  17, 5, 12  [emitted] [immutable]         pages/index
                    b9fa2d6.js  644 bytes         18  [emitted] [immutable]         pages/inspire
                    c34eed9.js   7.61 KiB      13, 3  [emitted] [immutable]         components/list-card-posts
                    e862f59.js  285 bytes         25  [emitted] [immutable]         pages/users/register/confirm
       fonts/Tanha.153f40c.ttf   78.1 KiB             [emitted] [immutable]
       fonts/Vazir.83fea74.ttf   82.6 KiB             [emitted] [immutable]
       fonts/Yekan.f6a0838.ttf   65.7 KiB             [emitted] [immutable]
 + 1 hidden asset
Entrypoint app = 907b2be.js 94b3b26.js 4815d83.js ac266d2.js

WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
  4815d83.js (637 KiB)
i [HPM] Proxy created: /api/  -> http://192.168.114.21:3000                                                                                                                                                                   19:31:42
i [HPM] Proxy rewrite rule created: "^/api/" ~> ""                                                                                                                                                                            19:31:42
i Generating output directory: dist/                                                                                                                                                                                          19:31:43
i Generating pages                                                                                                                                                                                                            19:31:43
√ Generated route "/inspire"                                                                                                                                                                                                  19:31:43
√ Generated route "/"                                                                                                                                                                                                         19:31:43
√ Generated route "/users/logout"                                                                                                                                                                                             19:31:43
√ Generated route "/users/login/confirm"                                                                                                                                                                                      19:31:43
√ Generated route "/users/register/confirm"                                                                                                                                                                                   19:31:43
√ Generated route "/cart"                                                                                                                                                                                                     19:31:43
√ Generated route "/users/login/register"                                                                                                                                                                                     19:31:43
√ Generated route "/users/profile"                                                                                                                                                                                            19:31:43
√ Client-side fallback created: 200.html     

and my project in github https://github.com/mohamadkhalili/store-v1

nuxt.config.js file

import colors from 'vuetify/es5/util/colors'

export default {
  // Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
  ssr: false,

  // Target: https://go.nuxtjs.dev/config-target
  target: 'static',
  server: {
    host: '0.0.0.0'
  },

  // Global page headers: https://go.nuxtjs.dev/config-head
  head: {
    titleTemplate: '%s - store-v1',
    title: 'store-v1',
    htmlAttrs: {
      lang: 'en'
    },
    meta: [
      {charset: 'utf-8'},
      {name: 'viewport', content: 'width=device-width, initial-scale=1'},
      {hid: 'description', name: 'description', content: ''},
      {name: 'format-detection', content: 'telephone=no'}
    ],
    link: [
      {rel: 'stylesheet', href: 'assets/web_fonts/tanha-font-v0.9/Tanha.ttf'},
      {rel: 'icon', type: 'image/x-icon', href: '/favicon.ico'}
    ]
  },


  // Global CSS: https://go.nuxtjs.dev/config-css
  css: [
    "~/assets/global.css",
  ],

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: ['~/plugins/farsiNumber.js'],

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

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
    // https://go.nuxtjs.dev/vuetify
    ['@nuxtjs/vuetify', {rtl: true,}],
  ],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
    // https://go.nuxtjs.dev/axios
    '@nuxtjs/axios',
  ],

  // Axios module configuration: https://go.nuxtjs.dev/config-axios
  axios: {
    proxy: true,
    baseURL: process.env.NODE_ENV !== "production"
      ? "process.env.BASE_URL"
      : "http://192.168.114.21:3000",
    proxyHeaders: true,
    credentials: true

  },
  proxy: {
    '/api/': {target: 'http://192.168.114.21:3000', pathRewrite: {'^/api/': ''}}
  },


  // Vuetify module configuration: https://go.nuxtjs.dev/config-vuetify
  vuetify: {
    customVariables: ['~/assets/variables.scss'],

    theme: {
      light: true,
      themes: {
        dark: {
          primary: colors.blue.darken2,
          accent: colors.grey.darken3,
          secondary: colors.amber.darken3,
          info: colors.teal.lighten1,
          warning: colors.amber.base,
          error: colors.deepOrange.accent4,
          success: colors.green.accent3
        }
      }
    }
  },
  router: {
    middleware: ['authenticated']
  },

  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {}
}
kissu
  • 40,416
  • 14
  • 65
  • 133
m kh
  • 372
  • 3
  • 15
  • What do you see during `yarn generate`? Can you see the actual route? What your generation code looks like? Can you check the `dist` directory? Can you host it on app.netlify.com/app just to be sure that this is not a hosting issue? – kissu Aug 29 '21 at 10:27
  • My host is properly. i use npm run generate. my route generateds: "/","product". i dont have id or slug in route after generate. also in dist. – m kh Aug 29 '21 at 11:47
  • 1
    I've checked your project, you have nothing that is leading to `pages/product/_id/_slug/index.vue` looking at your folder structure. On top of it, you have an error right from the index so I guess that the project cannot be run as is. If you want to generate some highly dynamic path, you'll need to do something like this https://stackoverflow.com/a/68431975/8816585 in your `nuxt.config.js` file (the `generate` part mainly). More info can be found with the documentation here: https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-generate#function-with-a-callback I cannot help more. – kissu Aug 31 '21 at 16:57

0 Answers0