Skip to content

Fix missing search box dimensions on prerendered pages - #63

Merged
pierosavi merged 1 commit into
mainfrom
prebuilt-pages-search-fix
Oct 12, 2026
Merged

pierosavi merged 1 commit into
mainfrom
prebuilt-pages-search-fix

Conversation

@pierosavi

Copy link
Copy Markdown
Member

The search box loads its dimensions (categories and manufacturers) from the API while the page is rendered. Prerendered pages (how-it-works, about, editorial-stance, imprint) render at build time. The Docker build has no API_AUTHORITY, so the request fails and these pages ship with dimensions="null".

On those pages, the search dropdown:

  • had no Category section
  • had no Manufacturer suggestions
  • showed a generic "unknown" icon for every device result

Device results, quick filters and the browse page were unaffected. Netlify builds can reach the API at build time, so the bug only showed up on the Docker deployment.

Fix

When dimensions is null, <device-search> now fetches it in the browser after the page loads. Pages rendered on request are unchanged and make no extra request.

Testing

Reproduce with a build that can't reach the API, then run the server with the real one:

DEPLOY_TARGET=node API_AUTHORITY=http://127.0.0.1:9 pnpm build
API_AUTHORITY=https://device-database.openhomefoundation.org PORT=4399 node ./dist/server/entry.mjs

On http://localhost:4399/how-it-works, the search dropdown shows Category and Manufacturer suggestions again.

@netlify

netlify Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for device-database-preview ready!

Name Link
🔨 Latest commit b1c5c50
🔍 Latest deploy log https://app.netlify.com/projects/device-database-preview/deploys/6ac92560847b8c0009d77b12
😎 Deploy Preview https://deploy-preview-63--device-database-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@pierosavi pierosavi changed the title Fix missing dimensions on prerendered pages Fix missing search box dimensions on prerendered pages Oct 9, 2026
@PhilipTrauner

Copy link
Copy Markdown
Collaborator

good catch!
this presently does not seem to work because the cors policy of /api/unstable/dimensions is too strict
how did you test this?

regardless, i'll approve this once i've applied the policy change on the server 🙏

@pierosavi

Copy link
Copy Markdown
Member Author

That’s right, I missed that, thanks for checking.
I tested it against the local API, which has cors() enabled on all routes, so I didn’t see the issue.

@PhilipTrauner PhilipTrauner left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

loosened the cors policy of the dimensions endpoint, this can go in!

caching also works as expected, which is nice 😁

thanks!

@pierosavi
pierosavi merged commit 4939042 into main Oct 12, 2026
7 checks passed
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