GithubHelp home page GithubHelp logo

Comments (9)

xavivars avatar xavivars commented on September 17, 2024

I'm facing the same problem than @brianbento. I'd love to have a way to fully disable that conditional check

from gatsby-plugin-static-site.

xavivars avatar xavivars commented on September 17, 2024

@wardpeet: this is also what I had to add to make it fully work: in gatsby-browser

exports.onClientEntry = () => {
    window.page = window.page || {};
    window.page.path = window.location.pathname;
}

Should this be added somehow to the plugin?

from gatsby-plugin-static-site.

wardpeet avatar wardpeet commented on September 17, 2024

Let me have a look next week as I'm currently in New York with the gatsby team

from gatsby-plugin-static-site.

brianbento avatar brianbento commented on September 17, 2024

@xavivars I'm actually having the path being updated before onClientEntry fires. By the time the code has loaded it path has already been changes to the one that gatsby expects.

The proposed fix actually causes the pathname to be duplicated.

https://example.com/foo becomes https://example.com/foo/foo

Also

https://example.com/foo/bar becomes https://example.com/foo/foo/bar

from gatsby-plugin-static-site.

xavivars avatar xavivars commented on September 17, 2024

I'm actually using it without a path now, but with an assetPrefix, and that works. Didn't try with path, but I guess you should be removing basepath from this so it doesn't get added twice window.page.path = window.location.pathname;

from gatsby-plugin-static-site.

wardpeet avatar wardpeet commented on September 17, 2024

I could fix this when adding assetPrefix: '/foo' to your gatsby-config.js

more info:
https://www.gatsbyjs.org/docs/asset-prefix/

This way your html files can live at / but your assets will live in /foo

from gatsby-plugin-static-site.

xavivars avatar xavivars commented on September 17, 2024

Maybe overriding match from "@reach/router/lib/utils" to always match could be a way to disable the the canonical redirect check... (but match is used also in the gatsby serve command, not sure if this plugin only affects build and not develop

from gatsby-plugin-static-site.

wardpeet avatar wardpeet commented on September 17, 2024

overriding utils wouldn't fix page-data requests.

I have a PR up that should fix this.
A demo: (page 5 has a canonical redirect)
https://static-asset-prefix--zen-wright-33c2d8.netlify.com

from gatsby-plugin-static-site.

wardpeet avatar wardpeet commented on September 17, 2024

I've published a new minor @wardpeet/gatsby-plugin-static-site 0.1.0. Please note that the minimum gatsby version is 2.11.1.

I'll be closing this issue, please reopen if it hasn't been resolved.

from gatsby-plugin-static-site.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.