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

rc-4 changes: Add additional headers to connect, reconnect endpoints on coordinator #1503

Merged

Conversation

mobile-bungalow
Copy link
Contributor

We need the ability to add additional headers in connect, reconnect. phoenix will throw a csrf error on live form submission unless content-type is set to application/x-www-form-urlencoded. This can already be done by changing the configured headers on the coordinator, but this is more explicit and avoid bugs where setting and unsetting them globally leaves them in the wrong state after a failed connection.

@bcardarella
Copy link
Collaborator

@mobile-bungalow are those needs in addition to this PR or part of this PR?

@mobile-bungalow
Copy link
Contributor Author

mobile-bungalow commented Dec 23, 2024

They are needed in addition to this PR, the changes need to happen in liveview-native-liveform upon submitting the form.

@bcardarella
Copy link
Collaborator

That doesn't sound correct to me. application/x-www-form-urlencoded is the older contet-type, multipart/form-data is the modern one. For example, the Fetch API in JavaScript will default to multipart/form-data for all POST requests. I think we should just have LVN Core default POST requests to multipart/form-data too but allow for an optional override of the content-type from the client if desired. However it is highly unlikely there will be a usecase for the downgraded content-type.

In otherwords, the clients should get something similar to the Fetch API that they can call from Core.

@bcardarella
Copy link
Collaborator

Actually, I'm incorrect. The Fetch API will only default to a multipart/form-data if the body is a FormData object.

@carson-katri carson-katri merged commit c9b944d into liveview-native:core-networking Dec 24, 2024
1 of 2 checks passed
carson-katri added a commit that referenced this pull request Dec 24, 2024
* Swift 6 language mode

* Exclude navigationViewStyle and disclosureGroupStyle

* Initial changes for using uniffi bindings

* Fix tests

* Updates to fix change closure

* Fix build after rebase

* Update for LVN Core `0.4.0-alpha-4`, remove Fragment handling

* Working LiveSocket/LiveChannel usage

* Update to include stylesheet and dead render

* Use LiveChannel.document and add LiveViewCoordinator.disconnect

* Add JsonEncoder to convert Encodable to LiveViewNativeCore.Json

* Add `JsonDecoder` to convert `Json` back into a `Decodable` type

* Add status listener

* Working navigation (with server-side error on phx_leave)

* Live reload

* Update to alpha 11 of lvn-core

* Fix build issues after rebase

* Fix build for Swift 6

* Surface connection errors

* Close live reload channel before socket disconnects

* Attempt to implement live session navigation

* Upgrades for rc-2

* Core file uploads (#1479)

* Swift 6 language mode

* Exclude navigationViewStyle and disclosureGroupStyle

* Initial changes for using uniffi bindings

* Working LiveSocket/LiveChannel usage

* Update to include stylesheet and dead render

* Add `fileImporter` support

* Pass mime type to fix file validation

* Apply reply payload from file validation

* Add public API for file uploads on FormModel

* Fix memory leaks

* Fix Swift frontend crash

* Cancel tasks on deinit

* Working file upload

---------

Co-authored-by: Sebastian Imlay <sebastian.imlay@gmail.com>

* Fix navigating backward multiple routes and error display

* Add file components

* Fix repeated uses of file upload forms

* Fix live reload

* Cleanup prints

* CSRF token debugging

* add additional headers (#1503)

* Create status and event streams inside Task

* Update for core rc-6

* regenerate modifiers

* Remove outdated tests

---------

Co-authored-by: Sebastian Imlay <sebastian.imlay@gmail.com>
Co-authored-by: mobile-bungalow <pwmay.work@gmail.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.

3 participants