vuepress / vuepress-community

:bulb: Community supported ecosystem for VuePress
https://vuepress-community.netlify.app
MIT License
81 stars 62 forks source link

[Bug Report] Locale redirects break when an h2 follows an h1 immediately #44

Closed TiEul closed 4 years ago

TiEul commented 4 years ago

Environment

Describe the bug

When a page has the following structure:

# Some title
## Another title
Some text

Redirects initiated by the redirect plugin will break the complete page. Only part of the page will updated, the other part will look like the home page. Browser will have these errors in their console:

Firefox:
DOMException: "Node.appendChild: Cannot add children to a Text"
Chrome:
DOMException: Failed to execute 'appendChild' on 'Node': This node type does not support this method.

Specific example (Removed links because I have fixed it by adding a paragraph to each page after the first header, issue remains however):

  1. Go here: /some/page.html
  2. You will be redirected to /en/some/page.html
  3. The page will give the correct title but the contents are taken from the root page and the website is in an unusable state.
  4. If you reload the page, the real contents will be shown and the website works fine. The website also works fine if you go to /en/some/page.html directly rather than first being redirected there by the redirect plugin.

This does not happen on pages which have a structure like this:

# Some title
Some text
## Another title
Some more text

It strictly seems to be related to cases where A title follows another title without text in between though it seems to do this reliably. I really cannot explain why this is not happening on my development environment but I suppose it's how Nginx handles the entry point somehow?! Either way, I would really appreciate some insights on this, I also don't fully know if it's a vuepress-community or vuepress issue.

Steps To Reproduce

I don't have any custom code on this server, just VuePress 1.5.0 and vuepress-plugin-redirect @ 1.2.3 with the locales redirect enabled.

This does not happen on my local environment and only on my Nginx environment which is configured as such:

server {
    listen 80 default_server;
    server_name _;
    return 301 https://$host$request_uri;
}

server {
        listen 443 default_server ssl;
    root /var/www/mywebsite.io/docs/.vuepress/dist;
        server_name mywebsite.io;
    index /en/index.html;

        ssl_certificate     /etc/letsencrypt/live/mywebsite.io/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mywebsite.io/privkey.pem;

    location / {
        try_files $uri $uri/ /en/index.html /404.html;
    }
}   

Screenshots

Expected behavior

Additional context

meteorlxy commented 4 years ago

Looks like a typical SSR mismatch problem. See here for detailed explanation.

Still, please provide a reproduce repo, so we can help to find the reason.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.