umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.43k stars 2.67k forks source link

Delivery Api redirects #16901

Open NikiSkaarup opened 1 month ago

NikiSkaarup commented 1 month ago

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

14.1.1, 13.4.1

Bug summary

Setting a domain that isn't starting with / in Culture and Hostnames on a root node breaks redirects in the delivery api, even when using the Start-Item header with the root node GUID

Initially thought it was related to https://github.com/umbraco/Umbraco-CMS/issues/14413 but it is functioning perfectly when a domain isn't configured or when it starts with a /

Specifics

/umbraco/delivery/api/v2/content/item/{path} to a renamed node

Steps to reproduce

  1. Add a domain in "Culture and Hostnames" on a root node.
  2. Rename a node under that root node.
  3. Attempt to use delivery api to fetch node by old path while using the root node GUID as Start-Item.
  4. observe instead of getting a redirect to the new url, it 404s without redirecting.

Expected result / actual result

Same behavior as either

Which is currently redirecting the new url if the path matches a redirect

Especially when Start-Item is set to the root node, I would expect it to look for redirects starting with the root node domains configured in Culture / Hostnames

github-actions[bot] commented 1 month ago

Hi there @NikiSkaarup!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:

jesperordrup commented 1 month ago

Possibly Related #16966

Any known workarounds?

NguyenThuyLan commented 2 weeks ago

Hi @NikiSkaarup , I want to ask why don't you configure domain to start with / ? It make sense it has to start with /for relative paths. otherwise it needs to be absolute e.g https://www.umbraco.com/

NikiSkaarup commented 2 weeks ago

Hi @NikiSkaarup , I want to ask why don't you configure domain to start with / ? It make sense it has to start with /for relative paths. otherwise it needs to be absolute e.g https://www.umbraco.com/

It is hosting multiple sites, and in order to ensure:

  1. cross site links are correct from the delivery api.
  2. prevent path collisions when two or more sites have the same paths. eg. /, /about

A domain has to be configured

NguyenThuyLan commented 2 weeks ago

Hi @NikiSkaarup , unfortunately I can't reproduce like this below https://github.com/user-attachments/assets/99851262-e020-4256-8f93-0558c84a6d66

I'm using v13.5.0, I have two root nodes ("Home" and "Lan page"), both of them have a under node "About" and changed to "About us" => as you can see I still can use /umbraco/delivery/api/v2/content/item/{path} to get with path "about" and it returns "301 Moved Permanently" instead of 404 Can you check with the latest versions of both v14 and v13 to see if this issue has been fixed or not?

NikiSkaarup commented 4 days ago

I can still replicate it just fine in 13.5.1 and 14.2.0

I've configured a root node with http://localhost:4443/

image

and then renamed a page called asdasd to dsadsa

image

after that I request http://localhost:4000/umbraco/delivery/api/v2/content/item/asdasd/ with the header Start-Item set to the website nodes GUID

and get back

{
  "type": "https://tools.ietf.org/html/rfc9110#section-15.5.5",
  "title": "Not Found",
  "status": 404,
  "traceId": "00-a60a27177453668189ff82c638f17d54-cdcc79d1bfe7fac7-00"
}

instead of being redirected to /dsadsa

EDIT: This is while using sqlite for the database, not sure if that affects this.