trunk icon indicating copy to clipboard operation
trunk copied to clipboard

Add config option to specify additional headers for serve

Open oberien opened this issue 3 years ago • 2 comments

I'm using webworkers (based on #285) and want to use SharedArrayBuffer. That requires setting the headers Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy: require-corp. To allow this configuration during development with trunk serve, I added a config option which allows specifying any number of header-value pairs, which are included in responses.

Checklist

  • [x] Updated CHANGELOG.md describing pertinent changes.
  • [ ] Updated README.md with pertinent info (may not always apply).
  • [ ] Updated site content with pertinent info (may not always apply).
  • [x] Squash down commits to one or two logical commits which clearly describe the work you've done. If you don't, then Dodd will 🤓.

oberien avatar Feb 17 '22 20:02 oberien

Is there any update on this? I'd like to add CORS headers in my local dev env.

iTitus avatar Jun 20 '22 18:06 iTitus

Thanks for the review. Unfortunately the changes have become pretty stale. I rebased and needed to completely change up the implementation. It works with the new ServeDir instead of the custom endpoint implementation now.

This time I ran rustfmt, so the imports should be in the correct order :)

oberien avatar Jul 03 '22 15:07 oberien

Hi, @thedodd. Is anything blocking this PR? I also faced #414 in my project. I overlooked this PR and even prepared my own. (available here, the approach is slightly different, I also updated docs and added an example)

I'd love to see this merged and released. It's quite a simple feature that helps tremendously.

vitvakatu avatar Nov 02 '22 20:11 vitvakatu

I also would love to see this merged. It looks like GitHub is saying that this branch is out-of-date with the base branch. I'll be willing to try to rebase it to the master and make other changes if needed.

SeanOMik avatar Nov 12 '22 04:11 SeanOMik

Rebased to the latest master. Is there anything else I can do to help move this PR along? (The 2 clippy lints don't affect code I changed.)

oberien avatar Nov 12 '22 15:11 oberien

Thanks for this PR. Look forward to its progress.

chaosprint avatar Feb 16 '23 14:02 chaosprint

Are there any updates on the possibility of merging this to the upstream?

Cornul11 avatar Mar 15 '23 23:03 Cornul11

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

github-actions[bot] avatar Oct 20 '23 00:10 github-actions[bot]

I merged this into trunk-ng, if it looks good for the next few days, it should be released as 0.17.11.

It would be great if any of you could test this feature specifically. You need to install trunk-ng from git for doing so: cargo install --git https://github.com/ctron/trunk --branch trunk-ng

ctron avatar Oct 20 '23 07:10 ctron

I tested trunk-ng and it seems to work just fine. I can't tell a difference in behaviour between my branch and trunk-ng.

oberien avatar Oct 21 '23 19:10 oberien

This is now released with trunk-ng 0.17.11

ctron avatar Oct 24 '23 08:10 ctron

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

github-actions[bot] avatar Dec 10 '23 00:12 github-actions[bot]

This PR is not stale. The feature is used by several people and has even been integrated into trunk-ng.

oberien avatar Dec 11 '23 08:12 oberien

This was brought back to trunk with PR https://github.com/trunk-rs/trunk/pull/623 and it should be part of the next release of trunk too.

ctron avatar Dec 12 '23 08:12 ctron

This was released with trunk 0.18.0.

ctron avatar Dec 13 '23 10:12 ctron