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

vary origin on delegated options #292

Merged
merged 3 commits into from
Jan 27, 2024
Merged

vary origin on delegated options #292

merged 3 commits into from
Jan 27, 2024

Conversation

laat
Copy link
Contributor

@laat laat commented Jan 27, 2024

When the options used are delegated to a function, then the origin could be dynamic and should add vary: origin header.

The symbol usage feels a bit hacky, but the test changes should be ok.

fixes #291

Checklist

@laat laat changed the title vary on delegated options vary origin on delegated options Jan 27, 2024
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina
Copy link
Member

@saschanaz could you review as well?

How much of this PR is reverting the original change?

@laat
Copy link
Contributor Author

laat commented Jan 27, 2024

How much of this PR is reverting the original change?

The spirit of the original change is still there, that when we have a static or '*' origin then we should not add the vary header. It's just that dynamic config through a callback can make the origin dynamic. The other dynamic config possibilities was handled in the original PR.

climba03003

This comment was marked as outdated.

index.js Show resolved Hide resolved
@Fdawgs Fdawgs requested a review from a team January 27, 2024 08:25
Copy link
Contributor

@saschanaz saschanaz left a comment

Choose a reason for hiding this comment

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

LGTM in terms of the behavior, as my intention of the patch was only for static options.

Sorry for the churn and thank you for the fix.

Copy link
Member

@climba03003 climba03003 left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina merged commit 034bb13 into fastify:master Jan 27, 2024
18 checks passed
@laat laat deleted the vary-delegated-options branch January 27, 2024 17:25
}
})
}

/**
* @param {import('./types').FastifyCorsOptions} opts
*/
function normalizeCorsOptions (opts) {
function normalizeCorsOptions (opts, dynamic) {
Copy link
Member

Choose a reason for hiding this comment

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

function normalizeCorsOptions (opts, dynamic = false) {

@@ -148,11 +148,12 @@ function normalizeCorsOptions (opts) {
// strings are applied directly and any other value is ignored
corsOptions.cacheControl = null
}
corsOptions.dynamic = dynamic || false
Copy link
Member

Choose a reason for hiding this comment

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

Late to the party:
why didn't we set it during the declaration?

@Uzlopak
Copy link
Contributor

Uzlopak commented Jan 28, 2024

@Eomm
You are little bit too late. It is already merged

@Eomm
Copy link
Member

Eomm commented Jan 28, 2024

Yeah, but it is not released 😈

@mortenkjelling
Copy link

Can it be released soon though?

@mcollina
Copy link
Member

shipped

renovate bot referenced this pull request in tomacheese/telcheck Feb 3, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@fastify/cors](https://togithub.com/fastify/fastify-cors) | [`9.0.0`
->
`9.0.1`](https://renovatebot.com/diffs/npm/@fastify%2fcors/9.0.0/9.0.1)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@fastify%2fcors/9.0.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@fastify%2fcors/9.0.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@fastify%2fcors/9.0.0/9.0.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@fastify%2fcors/9.0.0/9.0.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>fastify/fastify-cors (@&#8203;fastify/cors)</summary>

###
[`v9.0.1`](https://togithub.com/fastify/fastify-cors/releases/tag/v9.0.1)

[Compare
Source](https://togithub.com/fastify/fastify-cors/compare/v9.0.0...v9.0.1)

#### What's Changed

- vary origin on delegated options by
[@&#8203;laat](https://togithub.com/laat) in
[https://github.com/fastify/fastify-cors/pull/292](https://togithub.com/fastify/fastify-cors/pull/292)

#### New Contributors

- [@&#8203;laat](https://togithub.com/laat) made their first
contribution in
[https://github.com/fastify/fastify-cors/pull/292](https://togithub.com/fastify/fastify-cors/pull/292)

**Full Changelog**:
fastify/fastify-cors@v9.0.0...v9.0.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **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/tomacheese/telcheck).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xNTMuMiIsInVwZGF0ZWRJblZlciI6IjM3LjE1My4yIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIn0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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.

Vary with dynamic config
7 participants