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

Delivery API: behavior of redirection after renaming Node #14413

Closed
cf-marc opened this issue Jun 19, 2023 · 7 comments
Closed

Delivery API: behavior of redirection after renaming Node #14413

cf-marc opened this issue Jun 19, 2023 · 7 comments
Assignees
Labels
state/needs-more-info We don't have enough information to give a good reply state/needs-reproduction Check if this can be reproduced in the latest released version type/bug

Comments

@cf-marc
Copy link

cf-marc commented Jun 19, 2023

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

12.0.0-rc3

Bug summary

If you rename an item in Umbraco e.g. from 'About' to 'About us' and try to get the Item with the old path '/umbraco/delivery/api/v1/content/item/about', you will be redirected to the path '/about-us'.

Specifics

No response

Steps to reproduce

  1. Create a Node in Umbraco e.g. 'About'
  2. Save and publish
  3. Rename created Node to 'About Us'
  4. Call API with old path '/umbraco/delivery/api/v1/content/item/about'

Expected result / actual result

Actual response:

<section>
	<article>
		<div>
			<h1>Page Not Found</h1>
			<h3>No template exists to render the document at URL &#x27;/about-us&#x27;.</h3>
			<div class="cta"></div>
			<div class="row">
				<div class="col">
					<h2>This page can be replaced</h2>
					<p>
						Custom error handling might make your site look more on-brand and minimize the impact of
						errors on user experience - for example, a custom 404 with some helpful links (or a search
						function) could bring some value to the site.
					</p>

					<a href="https://umbra.co/custom-error-pages" target="_blank" rel="noopener">Implementing custom
						error pages &rarr;</a>
				</div>

				<div class="col">
					<h2>Be a part of the community</h2>
					<p>The Umbraco community is the best of its kind, be sure to visit, and if you have any
						questions, we're sure that you can get your answers from the community.</p>

					<a href="https://our.umbraco.com/" target="_blank" rel="noopener">our.Umbraco &rarr;</a>
				</div>
			</div>
		</div>
	</article>

</section>

Expected result:

{
    "name": "About Us",
    "route": {
        "path": "/about-us",
        "startItem": {
            "id": "5574d0fe-7c0a-4574-8857-f74413d9ce49",
            "path": "root"
        }
    },
    "id": "769e2d4c-6366-4db2-b4d4-e8301f56e3c7",
    "contentType": "content",
    "cultures": {
        "de-ch": {
            "path": "/about-us",
            "startItem": {
                "id": "5574d0fe-7c0a-4574-8857-f74413d9ce49",
                "path": "root"
            }
        }
    }
}

or at lead a valid json response:

{
    "type": "https://tools.ietf.org/html/rfc7231#section-6.5.4",
    "title": "Not Found",
    "status": 404,
    "traceId": "00-8eb2e90c3c80cd055cca865c48aed1d1-f622785079defc70-00"
}
@github-actions
Copy link

Hi there @cf-marc!

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'll assess whether this issue relates to something that has already been fixed in a later version of the release that it has been raised for.
  • If it's a bug, is it related to a release that we are actively supporting or is it related to a release that's in the end-of-life or security-only phase?
  • We'll replicate the issue to ensure that the problem is as described.
  • We'll decide whether the behavior is an issue or if the behavior is intended.

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 🤖 🙂

@cf-marc cf-marc changed the title Delivery API: behavior of redirection after renaming Delivery API: behavior of redirection after renaming Node Jun 19, 2023
@kjac
Copy link
Contributor

kjac commented Jun 20, 2023

Hi @cf-marc 👋

Thank you for reporting this 👍

The API should return a valid redirect response, but perhaps something broke. I'll dive into this today and get back to you 😄

@kjac kjac self-assigned this Jun 20, 2023
@kjac
Copy link
Contributor

kjac commented Jun 20, 2023

Ok... I can't reproduce this 🙈

I have a content item that was renamed from "Delete Me Too" to "Delete Me Too Too Shoo":

image

When I request /umbraco/delivery/api/v1.0/content/item/delete-me-too I get a HTTP301 Moved Permanently response:

image

If you're testing this in Postman or a similar tool, it might be that the tool automatically follows redirects. Postman does so by default; you have to go to Settings to turn that off explicitly:

image

Alternatively (provided you use Postman) you can open the Postman console and see the HTTP301:

image

Could I ask you to test this again?

@kjac kjac added state/needs-more-info We don't have enough information to give a good reply state/needs-reproduction Check if this can be reproduced in the latest released version labels Jun 20, 2023
@cf-marc
Copy link
Author

cf-marc commented Jun 20, 2023

Hey @kjac

Thanks for the input and sorry for that. I switched off this setting in postman and the response is absolutely fine.

@cf-marc cf-marc closed this as completed Jun 20, 2023
@kjac
Copy link
Contributor

kjac commented Jun 20, 2023

Awesome @cf-marc 🥳 and thank you for taking the time to test the API 💪

@thebuilder
Copy link

@kjac Was this actually solved? Or what's the solution?
Shouldn't the Content Delivery API follow the redirect and return the correct JSON?

Do we need to disable redirects, and manually handle the redirects?

@thebuilder
Copy link

Okay, it "kinda" makes sense, since it returns the actual URL for the page you requested.

I've set redirect to manual, and if i get back a 301, i perform a page redirect.

export default async function Page({ params }: Props) {
  const result = await fetchUmbracoPath(params.slug);

  if (result.response.status === 301) {
    // Content was moved.
    redirect(result.response.headers.get("Location")!);
  }
  ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state/needs-more-info We don't have enough information to give a good reply state/needs-reproduction Check if this can be reproduced in the latest released version type/bug
Projects
None yet
Development

No branches or pull requests

3 participants