question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

False positive prefetch external error when deployed to GitHub pages

See original GitHub issue

Describe the bug

Not quite sure what’s going wrong and if this is really a bug or misconfiguration on my part.

Trying to deploy this app to GitHub pages at https://janosh.github.io/periodic-table, all internal links log console errors:

Uncaught (in promise) Error: Attempted to prefetch a URL that does not belong to this app: https://janosh.github.io/periodic-table/polonium

The error is raised here:

https://github.com/sveltejs/kit/blob/f87d55b6d5d425c395e0c2585da28fdf1e27ab81/packages/kit/src/runtime/client/client.js#L217

and might be due to URLs incorrectly classified as external here (hard to say with minified stack trace in prod and can’t reproduce in dev)

https://github.com/sveltejs/kit/blob/f87d55b6d5d425c395e0c2585da28fdf1e27ab81/packages/kit/src/runtime/client/client.js#L1002-L1003

data-sveltekit-prefetch is set globally on the body.

Reproduction

Doesn’t repro on StackBlitz as I think it’s related to serving the app on a non-root URL with a <base> tag as suggested in #7733.

Logs

No response

System Info

System:
    OS: macOS 13.0
    CPU: (10) arm64 Apple M1 Pro
    Memory: 88.06 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.9.0 - /opt/homebrew/bin/node
    npm: 8.19.1 - /opt/homebrew/bin/npm
  Browsers:
    Brave Browser: 107.1.45.127
    Chrome: 107.0.5304.110
    Safari: 16.1
  npmPackages:
    @sveltejs/adapter-static: 1.0.0-next.48 => 1.0.0-next.48 
    @sveltejs/kit: 1.0.0-next.553 => 1.0.0-next.553 
    svelte: ^3.53.1 => 3.53.1 
    vite: ^3.2.4 => 3.2.4

Severity

annoyance

Additional Information

No response

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
dummdidummcommented, Nov 22, 2022

The docs are correct. They omitted the alternative way with the base path though, which we should probably add (it has caveats though, which is why it’s left out though).

What I mean is that you add the base setting to your svelte.config.js like you did here and adjust your base path injection here to <base href={base} /> (with import { base } from '$app/paths'), but don’t adjust all your <a href tags, and then report back if this worked.

0reactions
janoshcommented, Nov 22, 2022

Sorry, for some reason I thought I saw a commit where you did <a href="{base}/path/to/page">...</a>.

Yes, there was one. I force-pushed. Sorry for the confusion. That commit had the same external prefetch console errors though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Build errors during deployment to GitHub Pages · Issue #209
I am failed to deploy the ai-folio theme in my personal repository. Even I don't find any fruitful reason why it is happening....
Read more >
Failure deployed on Github Pages · Discussion #23609
I mean, if I try to add something to the repository on Gihub Pages, some changes to my website, Github Pages doesn't update...
Read more >
About Jekyll build errors for GitHub Pages sites
You're using a CI service that isn't configured to build your publishing source. For example, Travis CI won't build the gh-pages branch unless...
Read more >
HTML Standard
Continuing the above example, a requirement stating that a particular attribute's value is constrained to being a valid integer emphatically does not imply ......
Read more >
Gatsby Changelog | 5.3.0
Gatsby printed the complete contents of the page data to the terminal. ... dhoko: feat(gatsby-source-wordpress): Fix false positive error if the URL and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found