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

fix: should SSR render if accept header includes */* #5234

Merged

Conversation

SamVerschueren
Copy link
Contributor

Overview

If I start a Qwik app and use curl to make a GET request to the home page, Qwik returns a 404.

❯ curl -vv http://localhost:5173
*   Trying 127.0.0.1:5173...
* connect to 127.0.0.1 port 5173 failed: Connection refused
*   Trying [::1]:5173...
* Connected to localhost (::1) port 5173 (#0)
> GET / HTTP/1.1
> Host: localhost:5173
> User-Agent: curl/8.1.2
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< Access-Control-Allow-Origin: *
< cache-control: max-age=5, stale-while-revalidate=604800
< Content-Security-Policy: default-src 'none'
< X-Content-Type-Options: nosniff
< Content-Type: text/html; charset=utf-8
< Content-Length: 139
< Date: Thu, 28 Sep 2023 13:53:22 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
< 
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /</pre>
</body>
</html>

The reason is that curl uses Accept: */* by default, which is not caught by the middleware because shouldSsrRender() returns false in that case.

What is it?

  • Feature / enhancement
  • Bug
  • Docs / tests / types / typos

Description

See Overview

Use cases and why

When running curl -vv http://localhost:5173 to get the home page of your Qwik app, I expect that it returns the html instead of a 404. Currently that only works if you run curl -vv -H "Accept: text/html" http://localhost:5173.

Checklist:

  • My code follows the developer guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • Added new tests to cover the fix / functionality

@netlify
Copy link

netlify bot commented Sep 28, 2023

👷 Deploy request for qwik-insights pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 6534d6c

Copy link
Contributor

@mhevery mhevery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution. ❤️

@mhevery mhevery merged commit a79bd06 into QwikDev:main Sep 28, 2023
20 checks passed
kodiakhq bot referenced this pull request in ascorbic/unpic-img Oct 8, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@builder.io/qwik](https://qwik.builder.io/) ([source](https://togithub.com/BuilderIO/qwik)) | [`1.2.12` -> `1.2.13`](https://renovatebot.com/diffs/npm/@builder.io%2fqwik/1.2.12/1.2.13) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@builder.io%2fqwik/1.2.13?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@builder.io%2fqwik/1.2.13?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@builder.io%2fqwik/1.2.12/1.2.13?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@builder.io%2fqwik/1.2.12/1.2.13?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>BuilderIO/qwik (@&#8203;builder.io/qwik)</summary>

### [`v1.2.13`](https://togithub.com/BuilderIO/qwik/releases/tag/v1.2.13)

[Compare Source](https://togithub.com/BuilderIO/qwik/compare/v1.2.12...v1.2.13)

#### What's Changed

-   fix(insights): wrapper style by [@&#8203;gioboa](https://togithub.com/gioboa) in [https://github.com/BuilderIO/qwik/pull/5193](https://togithub.com/BuilderIO/qwik/pull/5193)
-   docs: fix typos by [@&#8203;igorbabko](https://togithub.com/igorbabko) in [https://github.com/BuilderIO/qwik/pull/5195](https://togithub.com/BuilderIO/qwik/pull/5195)
-   fix(qwik-auth): allow multiple set-cookie headers by [@&#8203;ulic75](https://togithub.com/ulic75) in [https://github.com/BuilderIO/qwik/pull/5194](https://togithub.com/BuilderIO/qwik/pull/5194)
-   feat(insights): return prefetch list per route by [@&#8203;mhevery](https://togithub.com/mhevery) in [https://github.com/BuilderIO/qwik/pull/5197](https://togithub.com/BuilderIO/qwik/pull/5197)
-   feat(insights): return prefetch list per route by [@&#8203;mhevery](https://togithub.com/mhevery) in [https://github.com/BuilderIO/qwik/pull/5198](https://togithub.com/BuilderIO/qwik/pull/5198)
-   chore(qwik-auth): v0.1.3 by [@&#8203;mhevery](https://togithub.com/mhevery) in [https://github.com/BuilderIO/qwik/pull/5201](https://togithub.com/BuilderIO/qwik/pull/5201)
-   feat(cli): add barrel template to `new` command by [@&#8203;dapids](https://togithub.com/dapids) in [https://github.com/BuilderIO/qwik/pull/5202](https://togithub.com/BuilderIO/qwik/pull/5202)
-   docs: add `dimension.dev` to showcase by [@&#8203;necatikcl](https://togithub.com/necatikcl) in [https://github.com/BuilderIO/qwik/pull/5200](https://togithub.com/BuilderIO/qwik/pull/5200)
-   fix(core): Added StringSerializer for strings that start with the prefixes of serializers. by [@&#8203;genki](https://togithub.com/genki) in [https://github.com/BuilderIO/qwik/pull/5176](https://togithub.com/BuilderIO/qwik/pull/5176)
-   fix(serializers): fix for serialization of an empty set or map by [@&#8203;Varixo](https://togithub.com/Varixo) in [https://github.com/BuilderIO/qwik/pull/5209](https://togithub.com/BuilderIO/qwik/pull/5209)
-   docs: add qwik-spin-delay library by [@&#8203;harshmangalam](https://togithub.com/harshmangalam) in [https://github.com/BuilderIO/qwik/pull/5214](https://togithub.com/BuilderIO/qwik/pull/5214)
-   docs(ecosystem): add qwik-image library by [@&#8203;gioboa](https://togithub.com/gioboa) in [https://github.com/BuilderIO/qwik/pull/5216](https://togithub.com/BuilderIO/qwik/pull/5216)
-   chore: add prettier-plugin-tailwindcss to tailwind starter ([#&#8203;5217](https://togithub.com/BuilderIO/qwik/issues/5217)) by [@&#8203;nsdonato](https://togithub.com/nsdonato) in [https://github.com/BuilderIO/qwik/pull/5217](https://togithub.com/BuilderIO/qwik/pull/5217)
-   docs: Correct image size and CLS in resumable example by [@&#8203;mhevery](https://togithub.com/mhevery) in [https://github.com/BuilderIO/qwik/pull/5220](https://togithub.com/BuilderIO/qwik/pull/5220)
-   docs: fix url for useVisibleTask by [@&#8203;nsdonato](https://togithub.com/nsdonato) in [https://github.com/BuilderIO/qwik/pull/5223](https://togithub.com/BuilderIO/qwik/pull/5223)
-   feat: bootstrap integration adapter  by [@&#8203;mhevery](https://togithub.com/mhevery) in [https://github.com/BuilderIO/qwik/pull/5222](https://togithub.com/BuilderIO/qwik/pull/5222)
-   chore: update file path in next-steps.tsx by [@&#8203;Craiqser](https://togithub.com/Craiqser) in [https://github.com/BuilderIO/qwik/pull/5212](https://togithub.com/BuilderIO/qwik/pull/5212)
-   refactor: remove extraneous isElement call by [@&#8203;wmertens](https://togithub.com/wmertens) in [https://github.com/BuilderIO/qwik/pull/5210](https://togithub.com/BuilderIO/qwik/pull/5210)
-   docs: fix edit this page for deprecated features by [@&#8203;nsdonato](https://togithub.com/nsdonato) in [https://github.com/BuilderIO/qwik/pull/5224](https://togithub.com/BuilderIO/qwik/pull/5224)
-   chore: update firebase starter to contemplate dist folder by [@&#8203;nsdonato](https://togithub.com/nsdonato) in [https://github.com/BuilderIO/qwik/pull/5225](https://togithub.com/BuilderIO/qwik/pull/5225)
-   feat(cachecontrol): add second `target` argument to cacheControl by [@&#8203;maiieul](https://togithub.com/maiieul) in [https://github.com/BuilderIO/qwik/pull/5226](https://togithub.com/BuilderIO/qwik/pull/5226)
-   fix: should SSR render if accept header includes */* by [@&#8203;SamVerschueren](https://togithub.com/SamVerschueren) in [https://github.com/BuilderIO/qwik/pull/5234](https://togithub.com/BuilderIO/qwik/pull/5234)
-   docs: fix 404 links by [@&#8203;mhevery](https://togithub.com/mhevery) in [https://github.com/BuilderIO/qwik/pull/5236](https://togithub.com/BuilderIO/qwik/pull/5236)
-   docs: Add frostytools.com to pages.json by [@&#8203;n8sabes](https://togithub.com/n8sabes) in [https://github.com/BuilderIO/qwik/pull/5239](https://togithub.com/BuilderIO/qwik/pull/5239)
-   docs: fix typo by [@&#8203;the-r3aper7](https://togithub.com/the-r3aper7) in [https://github.com/BuilderIO/qwik/pull/5241](https://togithub.com/BuilderIO/qwik/pull/5241)
-   chore(contributing.md): remove unnecessary step to test against docs … by [@&#8203;maiieul](https://togithub.com/maiieul) in [https://github.com/BuilderIO/qwik/pull/5244](https://togithub.com/BuilderIO/qwik/pull/5244)
-   chore(contributing.md): added info when package linking doesn't work by [@&#8203;maiieul](https://togithub.com/maiieul) in [https://github.com/BuilderIO/qwik/pull/5245](https://togithub.com/BuilderIO/qwik/pull/5245)
-   docs: Build Showcase by [@&#8203;n8sabes](https://togithub.com/n8sabes) in [https://github.com/BuilderIO/qwik/pull/5242](https://togithub.com/BuilderIO/qwik/pull/5242)
-   docs: documentation link and text for directory-based routing by [@&#8203;ryo-manba](https://togithub.com/ryo-manba) in [https://github.com/BuilderIO/qwik/pull/5246](https://togithub.com/BuilderIO/qwik/pull/5246)
-   feat(labs): Add json debugging tool by [@&#8203;mhevery](https://togithub.com/mhevery) in [https://github.com/BuilderIO/qwik/pull/5259](https://togithub.com/BuilderIO/qwik/pull/5259)
-   feat(core): Allow useContext in same elem as provider by [@&#8203;wmertens](https://togithub.com/wmertens) in [https://github.com/BuilderIO/qwik/pull/5258](https://togithub.com/BuilderIO/qwik/pull/5258)
-   docs(routing): add Link prefetch documentation (alternative) by [@&#8203;maiieul](https://togithub.com/maiieul) in [https://github.com/BuilderIO/qwik/pull/5248](https://togithub.com/BuilderIO/qwik/pull/5248)
-   docs(labs): document devtools/json by [@&#8203;mhevery](https://togithub.com/mhevery) in [https://github.com/BuilderIO/qwik/pull/5260](https://togithub.com/BuilderIO/qwik/pull/5260)
-   fix(starter): localize configuration by [@&#8203;gioboa](https://togithub.com/gioboa) in [https://github.com/BuilderIO/qwik/pull/5262](https://togithub.com/BuilderIO/qwik/pull/5262)
-   docs: fix typos by [@&#8203;igorbabko](https://togithub.com/igorbabko) in [https://github.com/BuilderIO/qwik/pull/5265](https://togithub.com/BuilderIO/qwik/pull/5265)
-   docs(integrations): add valibot to modular forms guide by [@&#8203;fabian-hiller](https://togithub.com/fabian-hiller) in [https://github.com/BuilderIO/qwik/pull/5252](https://togithub.com/BuilderIO/qwik/pull/5252)
-   docs: Update SSG documentation to run build instead of preview by [@&#8203;ibousfiha](https://togithub.com/ibousfiha) in [https://github.com/BuilderIO/qwik/pull/5269](https://togithub.com/BuilderIO/qwik/pull/5269)
-   fix(starter): localize container attribute by [@&#8203;tzdesign](https://togithub.com/tzdesign) in [https://github.com/BuilderIO/qwik/pull/5268](https://togithub.com/BuilderIO/qwik/pull/5268)
-   fix: A bug fix [#&#8203;5104](https://togithub.com/BuilderIO/qwik/issues/5104) by [@&#8203;Charlygraphy23](https://togithub.com/Charlygraphy23) in [https://github.com/BuilderIO/qwik/pull/5267](https://togithub.com/BuilderIO/qwik/pull/5267)
-   docs(state): Add 'key' prop to list items by [@&#8203;nicvazquez](https://togithub.com/nicvazquez) in [https://github.com/BuilderIO/qwik/pull/5250](https://togithub.com/BuilderIO/qwik/pull/5250)
-   docs: add note about `onRequest` middleware exported from `serverAuth$` by [@&#8203;jakovljevic-mladen](https://togithub.com/jakovljevic-mladen) in [https://github.com/BuilderIO/qwik/pull/5264](https://togithub.com/BuilderIO/qwik/pull/5264)
-   docs(labs): update path for devtools to include https by [@&#8203;mhevery](https://togithub.com/mhevery) in [https://github.com/BuilderIO/qwik/pull/5271](https://togithub.com/BuilderIO/qwik/pull/5271)
-   docs: updated phrasing for clarity by [@&#8203;bodhicodes](https://togithub.com/bodhicodes) in [https://github.com/BuilderIO/qwik/pull/5273](https://togithub.com/BuilderIO/qwik/pull/5273)
-   fix: Bun adapter polyfill and redirect fix by [@&#8203;EamonHeffernan](https://togithub.com/EamonHeffernan) in [https://github.com/BuilderIO/qwik/pull/5272](https://togithub.com/BuilderIO/qwik/pull/5272)
-   fix: Pr local dev docker by [@&#8203;SauravChanda](https://togithub.com/SauravChanda) in [https://github.com/BuilderIO/qwik/pull/5237](https://togithub.com/BuilderIO/qwik/pull/5237)
-   refactor(core): remove useContextBoundary by [@&#8203;wmertens](https://togithub.com/wmertens) in [https://github.com/BuilderIO/qwik/pull/5274](https://togithub.com/BuilderIO/qwik/pull/5274)
-   fix: shell script update in README file by [@&#8203;harshmangalam](https://togithub.com/harshmangalam) in [https://github.com/BuilderIO/qwik/pull/5275](https://togithub.com/BuilderIO/qwik/pull/5275)
-   docs: improve advanced routing documentation by [@&#8203;jakovljevic-mladen](https://togithub.com/jakovljevic-mladen) in [https://github.com/BuilderIO/qwik/pull/5276](https://togithub.com/BuilderIO/qwik/pull/5276)
-   chore: 1.2.13 by [@&#8203;mhevery](https://togithub.com/mhevery) in [https://github.com/BuilderIO/qwik/pull/5277](https://togithub.com/BuilderIO/qwik/pull/5277)

#### New Contributors

-   [@&#8203;igorbabko](https://togithub.com/igorbabko) made their first contribution in [https://github.com/BuilderIO/qwik/pull/5195](https://togithub.com/BuilderIO/qwik/pull/5195)
-   [@&#8203;dapids](https://togithub.com/dapids) made their first contribution in [https://github.com/BuilderIO/qwik/pull/5202](https://togithub.com/BuilderIO/qwik/pull/5202)
-   [@&#8203;maiieul](https://togithub.com/maiieul) made their first contribution in [https://github.com/BuilderIO/qwik/pull/5226](https://togithub.com/BuilderIO/qwik/pull/5226)
-   [@&#8203;SamVerschueren](https://togithub.com/SamVerschueren) made their first contribution in [https://github.com/BuilderIO/qwik/pull/5234](https://togithub.com/BuilderIO/qwik/pull/5234)
-   [@&#8203;ryo-manba](https://togithub.com/ryo-manba) made their first contribution in [https://github.com/BuilderIO/qwik/pull/5246](https://togithub.com/BuilderIO/qwik/pull/5246)
-   [@&#8203;ibousfiha](https://togithub.com/ibousfiha) made their first contribution in [https://github.com/BuilderIO/qwik/pull/5269](https://togithub.com/BuilderIO/qwik/pull/5269)
-   [@&#8203;Charlygraphy23](https://togithub.com/Charlygraphy23) made their first contribution in [https://github.com/BuilderIO/qwik/pull/5267](https://togithub.com/BuilderIO/qwik/pull/5267)
-   [@&#8203;nicvazquez](https://togithub.com/nicvazquez) made their first contribution in [https://github.com/BuilderIO/qwik/pull/5250](https://togithub.com/BuilderIO/qwik/pull/5250)
-   [@&#8203;bodhicodes](https://togithub.com/bodhicodes) made their first contribution in [https://github.com/BuilderIO/qwik/pull/5273](https://togithub.com/BuilderIO/qwik/pull/5273)
-   [@&#8203;SauravChanda](https://togithub.com/SauravChanda) made their first contribution in [https://github.com/BuilderIO/qwik/pull/5237](https://togithub.com/BuilderIO/qwik/pull/5237)

**Full Changelog**: QwikDev/qwik@v1.2.12...v1.2.13

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 9pm on sunday" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/ascorbic/unpic-img).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjMiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjMiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=-->
mhevery added a commit that referenced this pull request Oct 13, 2023
In #5234 we added support
for requesting SSR with `curl` which defaults to `Accept: */*`.

The problem with that is that most image requests will trigger SSR
attempts. To fix this, special case the `*/*` and only SSR
if it is the only one.
mhevery added a commit that referenced this pull request Oct 13, 2023
In #5234 we added support
for requesting SSR with `curl` which defaults to `Accept: */*`.

The problem with that is that most image requests will trigger SSR
attempts. To fix this, special case the `*/*` and only SSR
if it is the only one.

Fix #5283
mhevery added a commit that referenced this pull request Oct 13, 2023
In #5234 we added support
for requesting SSR with `curl` which defaults to `Accept: */*`.

The problem with that is that most image requests will trigger SSR
attempts. To fix this, special case the `*/*` and only SSR
if it is the only one.

Fix #5283
mhevery added a commit that referenced this pull request Oct 13, 2023
In #5234 we added support
for requesting SSR with `curl` which defaults to `Accept: */*`.

The problem with that is that most image requests will trigger SSR
attempts. To fix this, special case the `*/*` and only SSR
if it is the only one.

Fix #5283
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants