Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asking for localized document responded with 404 error message #205

Open
luca-ferrari-ss opened this issue Nov 20, 2024 · 0 comments
Open
Labels
bug Something isn't working Needs investigation This needs some diving in to before it can be worked on

Comments

@luca-ferrari-ss
Copy link

luca-ferrari-ss commented Nov 20, 2024

Bug report

Describe the bug

Whenever I try to retrieve a localized document (being it a collection or a single type) the endpoint /webtools/router?path=... return a 404 error message.

Steps to reproduce the behavior

  1. Create two localization languages, such as english and italian (the default one).
  2. Create "page" collection, with one string field "title" (and set find permissions for public role).
  3. Create page patterns for both languages, such as "/[title]" for italian and "/en/[title]" for english.
  4. Create the first record for page collection and call it "Homepage", localize it.
  5. Go to "http://localhost:1337/api/webtools/router?path=/homepage", all good.
  6. Go to "http://localhost:1337/api/webtools/router?path=/en/homepage", 404 error.
  7. Go to "http://localhost:1337/api/webtools/url-alias", you should see the italian page but not the english one.
  8. On Strapi dashboard go to "Webtools -> All URLs" settings page. You should see both the italian and english urls in the list.
  9. Click on the edit button for the italian url "/homepage", all good.
  10. Click on the edit button for the english url "/en/homepage", nothing happens, you should see in the logs a 404 response, such as "http: GET /webtools/url-alias/editLink?path=/en/homepage (75 ms) 404".

Expected behavior

When is asked for localized versions of documents, the api should return the document itself, not a 404 error message.

Screenshots

Button to click for point number 10:

edit-error

Code snippets

Response of "http://localhost:1337/api/webtools/router?path=/homepage":

{
  "data": {
    "id": 1,
    "attributes": {
      "title": "Homepage",
      "createdAt": "2024-11-20T09:16:15.242Z",
      "updatedAt": "2024-11-20T09:17:03.265Z",
      "locale": "it",
      "contentType": "api::page.page"
    }
  },
  "meta": {

  }
}

Response of "http://localhost:1337/api/webtools/router?path=/en/homepage";

{
  "data": null,
  "error": {
    "status": 404,
    "name": "NotFoundError",
    "message": "Not Found",
    "details": {

    }
  }
}

Response of "http://localhost:1337/api/webtools/url-alias";

{
  "data": [
    {
      "id": 3,
      "attributes": {
        "url_path": "/homepage",
        "generated": true,
        "contenttype": "api::page.page",
        "createdAt": "2024-11-20T09:17:03.222Z",
        "updatedAt": "2024-11-20T09:17:03.311Z",
        "locale": "it"
      }
    }
  ],
  "meta": {
    "pagination": {
      "page": 1,
      "pageSize": 25,
      "pageCount": 1,
      "total": 1
    }
  }
}

Response of "http://localhost:1337/api/pages?locale=en&populate=url_alias":

{
  "data": [
    {
      "id": 2,
      "attributes": {
        "title": "Homepage",
        "createdAt": "2024-11-20T09:16:19.308Z",
        "updatedAt": "2024-11-20T09:17:03.304Z",
        "locale": "en",
        "url_alias": {
          "data": {
            "id": 4,
            "attributes": {
              "url_path": "/en/homepage",
              "generated": true,
              "contenttype": "api::page.page",
              "createdAt": "2024-11-20T09:17:03.272Z",
              "updatedAt": "2024-11-20T09:17:03.311Z",
              "locale": "en"
            }
          }
        }
      }
    }
  ],
  "meta": {
    "pagination": {
      "page": 1,
      "pageSize": 25,
      "pageCount": 1,
      "total": 1
    }
  }
}

System

  • Node.js version: 18.20.4
  • NPM version: 10.7.0
  • Strapi version: 4.25.9
  • Plugin version: 1.0.0-beta.15
  • Database: postgres 14.0
  • Operating system: macOS 14.6.1

Additional context

The localized documents seem not to be returned by the plugin, but the url seems to be generated correctly. The standard Strapi GET see the document and the path, as shown in the response of "http://localhost:1337/api/pages?locale=en&populate=url_alias".

@boazpoolman boazpoolman added bug Something isn't working Needs investigation This needs some diving in to before it can be worked on labels Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Needs investigation This needs some diving in to before it can be worked on
Projects
None yet
Development

No branches or pull requests

2 participants