elements icon indicating copy to clipboard operation
elements copied to clipboard

API with Set-Cookie not working

Open TheZwieback opened this issue 1 year ago • 2 comments

I have an API that returns an Set-Cookie header but the browser does not set the cookie properly using the elements openapi renderer for this endpoint. Other OpenAPI renderer work in this case. My guess is that the reason are omitted credentials see here: https://github.com/stoplightio/elements/blob/e0b10da220e9e9b49b2ec94fb1fa94d534a6a44f/packages/elements-core/src/components/TryIt/build-request.ts#L133

Context

Can't do basic testing via the UI as cookies are used in other API endpoints.

Current Behavior

Cookies not set in chrome or other browsers.

Expected Behavior

Cookie should be set.

Possible Workaround/Solution

None.

Steps to Reproduce

Don't have a live server sorry. Any API framework should be possible to write an endpoint in few lines. I have a Python litestar example if that helps, let me know.

Environment

  • Version used:
  • Environment name and version (e.g. Chrome 39, node.js 5.4):
  • Operating System and version (desktop or mobile):
  • Link to your environment/workspace/project:

TheZwieback avatar Jun 16 '24 17:06 TheZwieback

Does it work if you set Cookie as a header parameter and enter the value?

saper avatar Jun 21 '24 17:06 saper

https://docs.stoplight.io/docs/elements/b074dc47b2826-elements-configuration-options Could you try using the tryItCredentialsPolicy and set it to include or same-origin (depending on your use case) and see if that resolves your issue?

brendarearden avatar Jun 28 '24 14:06 brendarearden

@TheZwieback we are closing due to inactivity. Please try out the suggestion we have left. If that does not resolve the problem, please open another issue for further help.

brendarearden avatar Jul 10 '24 16:07 brendarearden