Skip to content

$page.query.get(..) returns null for prerendered pages #669

@falsetru

Description

@falsetru

Describe the bug
$page.query.get(...) returns null.

To Reproduce

git clone --branch issue-1 https://github.com/falsetru/sveltekit-test.git issue-1
cd issue-1
npm install
npm run build
npx sirv build/  # `npm run start` will hide the issue.

Expected behavior
abc printed, but got null.

Information about your SvelteKit Installation:

Diagnostics
  • The output of npx envinfo --system --npmPackages svelte,@sveltejs/kit,vite --binaries --browsers
  System:
    OS: Linux 5.8 Ubuntu 20.10 (Groovy Gorilla)
    CPU: (4) x64 Intel(R) Core(TM) i7-7600U CPU @ 2.80GHz
    Memory: 763.02 MB / 15.39 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 12.18.2 - /usr/bin/node
    npm: 7.7.6 - ~/.npm-packages/bin/npm
  Browsers:
    Chrome: 89.0.4389.114
    Firefox: 87.0
  npmPackages:
    @sveltejs/kit: next => 1.0.0-next.67 
    svelte: ^3.29.0 => 3.37.0 
    vite: ^2.1.0 => 2.1.5 
  • Your browser
    Google Chrome Version 89.0.4389.114 (Official Build) (64-bit)

  • Your adapter
    @sveltejs/adapter-static

Additional context

  • As a workaround, I am using new URLSearchParams(document.location.search).get('name').
  • If I modify
    query: new URLSearchParams(${s(request.query.toString())}),
    to
    query: new URLSearchParams(document.location.search),
    the issue is gone. Not sure whether it's proper way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions