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

[FR] Set global option for which port serve_site should use #770

Closed
ulyngs opened this issue Jan 10, 2025 · 2 comments · Fixed by #771
Closed

[FR] Set global option for which port serve_site should use #770

ulyngs opened this issue Jan 10, 2025 · 2 comments · Fixed by #771

Comments

@ulyngs
Copy link
Contributor

ulyngs commented Jan 10, 2025

Happy new year Yihui!

Sometimes one needs to always use a specific port when serving a site during local development (e.g. an API might only accepts requests from, say, localhost:3469).

It's possible to serve manually from a specific port with blogdown::serve_site(port = 3469).

However, it's not possible (as far as I could tell) to set a port to use in .Rprofile.

It'd be great if it was possible to set e.g. options(blogdown.serve_site.port = 3469) and then whenever serve_site is called, it's serving from that port.

@yihui
Copy link
Member

yihui commented Jan 10, 2025

The port can be set with the global option servr.port: https://git.yihui.org/servr/manual.html#sec:man-server_config

I understand that this is not obvious, but the ... arguments of blogdown::serve_site are passed to servr::server_config(), and you can configure the default values of them via servr.* options (or environment variables).

@ulyngs
Copy link
Contributor Author

ulyngs commented Jan 11, 2025

Ah I figured something like that might be the case!

I just submitted a pull request for an edit to this page on the blogdown documentation, which is where I was expecting to find that information when I was searching for it yesterday: #771

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 a pull request may close this issue.

2 participants