Strapi多语言内容发布报404错误求助
目标
我希望创建多语言内容,并在Next.js应用中获取这些内容以实现i18n国际化。
问题
为内容类型填充数据后发布草稿版本时,系统抛出「Not found」警告,对应的请求日志为:http: POST /content-manager/single-types/api::test.test/actions/publish?locale=es (15 ms) 404
已完成的排查步骤
- 已为公共用户和认证用户配置所有权限
- 已在全局设置的i18n中添加了对应 locales
- 已在内容类型构建器页面为该内容类型启用i18n
项目详情
{ "name": "protean-x-strapi", "private": true, "version": "0.1.0", "description": "A Strapi application", "scripts": { "develop": "strapi develop", "start": "strapi start", "build": "strapi build", "strapi": "strapi" }, "devDependencies": {}, "dependencies": { "@strapi/strapi": "4.21.1", "@strapi/plugin-users-permissions": "4.21.1", "@strapi/plugin-i18n": "4.21.1", "@strapi/plugin-cloud": "4.21.1", "better-sqlite3": "8.6.0", "react": "^18.0.0", "react-dom": "^18.0.0", "react-router-dom": "5.3.4", "styled-components": "5.3.3" }, "author": { "name": "A Strapi developer" }, "strapi": { "uuid": "2e6b5187-b712-4fe8-976c-849661638d60" }, "engines": { "node": ">=18.0.0 <=20.x.x", "npm": ">=6.0.0" }, "license": "MIT" }
求助
为何会遇到这个错误?我遗漏了什么配置?
我尝试删除build、node_modules、.strapi、.tmp文件夹后重新构建,但问题依然存在,求指点。
可能的解决方向
检查内容类型的草稿工作流配置
进入内容类型构建器的对应内容类型「高级设置」,确认「启用草稿和发布系统」选项已勾选。若之前未开启,勾选后需重启Strapi服务。验证Locale配置的一致性
检查全局i18n设置中添加的eslocale是否与请求参数完全匹配(注意大小写,比如是否应为es-ES),同时确认该内容类型的多语言设置中已添加es作为可用locale。确认具体内容类型的API权限
在「设置→角色与权限」中,针对Authenticated和Public角色,手动确认是否给api::test.test内容类型配置了publish动作的权限,全局权限配置可能未覆盖到具体动作。升级Strapi版本
你使用的4.21.1版本存在部分i18n相关bug,可升级至同系列最新稳定版(如4.21.6)后重新测试。确认内容草稿已保存
发布前需确保该locale下的内容已保存至少一个草稿版本,未保存的内容无法触发发布动作。检查数据库记录
查看SQLite数据库(.tmp/data.db)中的test表,确认是否存在locale=es的内容记录。若记录缺失,需重新创建该语言版本的内容。
内容的提问来源于stack exchange,提问作者Ritik Jangir

