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

feat(http): enable cookies and set origin header #1192

Merged
merged 12 commits into from
May 13, 2024

Conversation

amrbashir
Copy link
Member

closes #1167

@FabianLars
Copy link
Member

Do we need to make the origin configurable (including omitting it)? Or should we wait and see if users request that?

@amrbashir
Copy link
Member Author

I'd probably wait and see if there is any use-case to omitting/modifying it

plugins/http/src/lib.rs Outdated Show resolved Hide resolved
@amrbashir amrbashir requested a review from FabianLars May 13, 2024 15:29
@FabianLars
Copy link
Member

afaik just the feature flag alone doesn't do much, we have to enable cookie support on the builder too. I assume that we'll need to store our own cookie store/jar in a State to share cookies between fetch calls because we don't reuse clients anymore.

@amrbashir
Copy link
Member Author

I assume that we'll need to store our own cookie store/jar in a State to share cookies between fetch calls because we don't reuse clients anymore.

I think so, let me add that real quick

@amrbashir
Copy link
Member Author

should be good now

Copy link
Member

@FabianLars FabianLars left a comment

Choose a reason for hiding this comment

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

(i didn't test it)

@amrbashir amrbashir merged commit 58330f9 into v2 May 13, 2024
14 checks passed
@amrbashir amrbashir deleted the feat/http/cookies-origin-header branch May 13, 2024 22:39
@ToxicalNoob3062
Copy link

@amrbashir can you pls fix the error :

tauri-runtime-wry v2.0.0-beta.16
error[E0599]: no method named `as_str` found for enum `std::result::Result` in the current scope
   --> /home/rahat/.cargo/git/checkouts/plugins-workspace-fd0259fcb18f51ad/bd07784/plugins/http/src/commands.rs:249:72
    |
249 |                 request = request.header(header::ORIGIN, webview.url().as_str());
    |                                                                        ^^^^^^ method not found in `Result<Url, Error>`
    |
note: the method `as_str` exists on the type `reqwest::Url`
   --> /home/rahat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/url-2.5.0/src/lib.rs:581:5
    |
581 |     pub fn as_str(&self) -> &str {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: use the `?` operator to extract the `reqwest::Url` value, propagating a `Result::Err` value to the caller
    |
249 |                 request = request.header(header::ORIGIN, webview.url()?.as_str());
    |                                                                       +

For more information about this error, try `rustc --explain E0599`.
error: could not compile `tauri-plugin-http` (lib) due to previous error
warning: build failed, waiting for other jobs to finish...
error: script "tauri" exited with code 101`

It's a very small error ! but for this I can't compile the code of my app!

@amrbashir
Copy link
Member Author

amrbashir commented May 20, 2024

@ToxicalNoob3062 this is already fixed in #1325 and will be available in the next release, for now, ping tauri to a previous version until the next release of this plugin.

@FabianLars
Copy link
Member

Do we need to make the origin configurable (including omitting it)? Or should we wait and see if users request that?

Welp, 8 hours after release: #1389

@amrbashir
Copy link
Member Author

oh well, gotta open another PR

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.

[http] Use browser cookies [http] Cookies cannot be passed to the server in custom requests
3 participants