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

Implement basic 301 Redirect for DSpace 6.x URLs when SSR is used. #2331

Merged
merged 2 commits into from Jun 23, 2023

Conversation

tdonohue
Copy link
Member

@tdonohue tdonohue commented Jun 21, 2023

References

Description

Minor changes to the dso-redirect.service.ts to ensure it returns a 301 Moved Permanently redirect when running during server side rendering (SSR). This required changes to the existing HardRedirectService to support 301 redirects.

Added specs for all changes as well.

Instructions for Reviewers

@tdonohue tdonohue added bug component: SEO Search Engine Optimization labels Jun 21, 2023
@tdonohue tdonohue added this to the 7.6 milestone Jun 21, 2023
@tdonohue tdonohue self-assigned this Jun 21, 2023
@tdonohue
Copy link
Member Author

@artlowel : Wondering if you or someone on your team could glance at this? I was looking into fixing this SEO issue after talking to Google Scholar today, and this is a "basic fix" (may not be perfect, but it works). Not sure whether to go down this path for 7.6, or just press pause and work on a better fix for a later release.

@tdonohue tdonohue requested a review from artlowel June 21, 2023 20:56
@tdonohue tdonohue changed the title Implement basic 301 Redirect when SSR is used. Implement basic 301 Redirect for DSpace 6.x URLs when SSR is used. Jun 21, 2023
Copy link
Member

@artlowel artlowel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tdonohue!

This works. However I think the cleaner way to do it would be to use HardRedirectService for this. Its purpose is to handle redirects, and it already has separate implementations on the browser and server so you wouldn't need the platform check in DsoRedirectService

It would be slightly more complicated though, as we'd need the option to pass a 3xx status code as a param to HardRedirectService's redirect method (as currently it always redirects with a 302)

So if we still want to include this fix in 7.6 I'd use this PR. If it's not that urgent, perhaps wait for a PR based on HardRedirectService

@tdonohue
Copy link
Member Author

tdonohue commented Jun 22, 2023

@artlowel : I quickly refactored this to just use the HardRedirectService (adding an optional statusCode param). This is still working well for me. Could you give it a quick test / review tomorrow?

@tdonohue tdonohue requested a review from artlowel June 22, 2023 18:42
Copy link
Member

@artlowel artlowel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tdonohue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component: SEO Search Engine Optimization
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Return HTTP 301 to client when redirect occurs for old DSpace 6.x URLs
2 participants