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

missing trailing slash in page context url #1632

Closed
wants to merge 10 commits into from

Conversation

openscript
Copy link

fixes #1629

@openscript
Copy link
Author

I'm not sure how we can proceed with /en/index.pageContext.json/. Requests fetching page contexts fail.

@brillout
Copy link
Member

brillout commented May 2, 2024 via email

@openscript
Copy link
Author

openscript commented May 4, 2024

So far:

  • /en/index.pageContext.json?trailingSlash conflicts with query params a user might set
  • /en/index.pageContext.json/ breaks webserver routing
  • /en//index.pageContext.json write to file paths with double slash error

An alternative would be to add a property pageContext._urlHasTrailingSlash that is included in pageContext.json (i.e. in the default passToClient values see PASS_TO_CLIENT). That would be the cleanest I guess but maybe a little bit more cumbersome to implement.

I will follow that lead now.

@brillout
Copy link
Member

brillout commented May 4, 2024

@openscript Makes sense 👍

@openscript
Copy link
Author

Where would be a good place to update the url* contexts after the pageContext was fetched?

@brillout
Copy link
Member

brillout commented May 6, 2024

Actually, what we need is the other way around: we need the client to tell the server that the URL has a trailing slash. So I'm not sure pageContext._urlHasTrailingSlash would be of any help here.

@brillout
Copy link
Member

brillout commented May 6, 2024

How about this then:

  • /en => /en/index.pageContext.json
  • /en/ => /en/index.slash.pageContext.json

@brillout
Copy link
Member

brillout commented May 6, 2024

We can then use pageContext._urlHasTrailingSlash on the server-side only (no need to add it to passToClient).

@openscript
Copy link
Author

Is my thinking about the solution wrong? pageContext._urlHasTrailingSlash would be saved in the pageContext.json file. When the client fetches, it reads pageContext._urlHasTrailingSlash from the fetched pageContext.json, then it adjusts the urlOriginal etc.

Maybe it's better if you take over this issue. I feel a bit lost with it.

@brillout
Copy link
Member

The client-side is the source of truth. So the bottom line here is that the information needs to be communicated from the client to the server.

I thought more about it and I'm afraid there doesn't seem to a solution. The issue is that pre-rendering requires the pageContext.json file to be written at a unique path and, thus, served at a unique URL. So there isn't a way to determine whether there is a trailing a slash. I went a head and closed, but let me know if you know a framework that supports pre-rendering and trailing slashes and that doesn't have that issue, maybe I missed a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

urlParsed removes trailing slash
2 participants