Skip to content

Comments

Use nanonext http server for preview#2975

Open
shikokuchuo wants to merge 2 commits intor-lib:mainfrom
shikokuchuo:http-server
Open

Use nanonext http server for preview#2975
shikokuchuo wants to merge 2 commits intor-lib:mainfrom
shikokuchuo:http-server

Conversation

@shikokuchuo
Copy link
Member

@shikokuchuo shikokuchuo commented Feb 23, 2026

Summary

  • Serve previewed sites over http://127.0.0.1 (ephemeral port) instead of opening file:// paths directly, enabling dynamic features like the Algolia search bar that require HTTP to function.
  • The server persists across preview calls for the same site root and is replaced when switching sites.
  • Uses a lightweight C-level static directory server, bypassing R entirely after creation.
  • Adds nanonext (>= 1.8.0) to Imports.

Details

  • A package-level environment (the) caches the active server and its root path across calls within a session.
  • local_path() no longer appends index.html for directories since the HTTP server handles index resolution.
  • New tests cover server creation, reuse, replacement on root change, and URL construction for sub-paths.

@maelle
Copy link
Collaborator

maelle commented Feb 24, 2026

Cool! Another docs section that would need updating: https://pkgdown.r-lib.org/reference/build_search.html#debugging-and-local-testing

@shikokuchuo
Copy link
Member Author

@maelle thanks, updated now.

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