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

$page.query not available in production mode #2444

Closed
benmccann opened this issue Sep 16, 2021 · 4 comments
Closed

$page.query not available in production mode #2444

benmccann opened this issue Sep 16, 2021 · 4 comments
Labels
bug Something isn't working
Milestone

Comments

@benmccann
Copy link
Member

benmccann commented Sep 16, 2021

Describe the bug

It appears that, at least for adapter-static, $page.query is not available in production mode

Originally reported by @Abarnob in svelte-society/sveltesociety.dev#108

Reproduction

git clone [email protected]:svelte-society/sveltesociety.dev.git
cd sveltesociety.dev
git checkout staging
npm install
npm run build
cd build
python -m http.server 3000

If you navigate to http://localhost:3000/help/submitting?type=tool then the query parameter is ignored and the dropdown in not correctly populated. It works in dev mode

Logs

No response

System Info

npmPackages:
    @sveltejs/adapter-static: next => 1.0.0-next.18 
    @sveltejs/kit: next => 1.0.0-next.162 
    svelte: ^3.38.2 => 3.42.4

Severity

serious, but I can work around it

Additional Information

No response

@benmccann benmccann added the bug Something isn't working label Sep 16, 2021
@benmccann benmccann added this to the 1.0 milestone Sep 16, 2021
@Conduitry
Copy link
Member

Is this the essentially the same as #1825/#2262, which were working-as-designed?

@benmccann
Copy link
Member Author

Ah, yes, you're right. It's really not obvious 😄 #2363 would solve this so that users can't make that mistake

@scorsi
Copy link

scorsi commented Nov 8, 2021

Here is a potential workaround client-side only :

// import { page } from '$app/stores';
import { browser } from '$app/env';

export let param /* = $page.query.get('param') */;

$: {
	if (browser) {
		const urlParams = new URLSearchParams(window.location.search);
		param = urlParams.get('param');
	}
}

@Conduitry
Copy link
Member

@benmccann Can we close this in favor of #2361? It doesn't sound to me like there's anything else going on here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants