我如何在生产模式下自定义 nextjs URL
How can i custom nextjs URL in production mode
当我使用 npm 运行 启动我的下一个项目时,我得到了 http://localhost:3000/cart but what i want is for the cart.js is to visit via http://localhost:3000/myprojectname/cart I try to use set in next.config.js with exportpathmap it works well in npm run dev but when i start program with npm run start it doesn't work as i expected how can i get URL path like this http://localhost:3000/myprojectname/cart instead of http://localhost:3000/cart 的购物车页面
您想在项目的 pages
文件夹中创建一个名为 myprojectname
的文件夹。然后在文件夹内,移动 cart.js.
它的作用是向您的 URL 添加一个 /myprojectname/
路由并访问购物车,您必须像这样访问它:/myprojectname/cart
这就是 NextJS 根据您构建目录的方式进行路由的方式。
更多信息可以参考这个link:https://nextjs.org/learn/basics/navigate-between-pages
当我使用 npm 运行 启动我的下一个项目时,我得到了 http://localhost:3000/cart but what i want is for the cart.js is to visit via http://localhost:3000/myprojectname/cart I try to use set in next.config.js with exportpathmap it works well in npm run dev but when i start program with npm run start it doesn't work as i expected how can i get URL path like this http://localhost:3000/myprojectname/cart instead of http://localhost:3000/cart 的购物车页面
您想在项目的 pages
文件夹中创建一个名为 myprojectname
的文件夹。然后在文件夹内,移动 cart.js.
它的作用是向您的 URL 添加一个 /myprojectname/
路由并访问购物车,您必须像这样访问它:/myprojectname/cart
这就是 NextJS 根据您构建目录的方式进行路由的方式。
更多信息可以参考这个link:https://nextjs.org/learn/basics/navigate-between-pages