Sardoan
Hi,
I am using scrivener headers in my app and the cors_plug. It seems cors_plug removes the headers generated by scrivener. I am consuming my phoenix api with a javascript client.
I would like to add the headers, so I can use the pagination, but no idea how to add them to the configuration.
I use in my endpoin.ex this configuration: plug CORSPlug, origin: ~r/http:\/\/localhost:3333$|https:\/\/.*\.xxx$/
How can I add the Access-Control-Expose-Headers to my endpoint?
With the jquery ajax call and request.getAllResponseHeaders() I get only the default headers (header spec)
With Postman and Browser the headers are visible.
I am a bit lost.
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
amnu3387
You can add a
headerskeyI use this on my endpoints
I think you need to add all headers there, you can view in the corsplug repository the default headers, copy them and add your own to the list
Sardoan
Checked the defaults before:
headers: ["Authorization", "Content-Type", "Accept", "Origin", "User-Agent", "DNT","Cache-Control", "X-Mx-ReqToken", "Keep-Alive", "X-Requested-With", "If-Modified-Since", "X-CSRF-Token"]Did not know how to add the link, page… headers from scrivener headers to it, since not mentioned in the docs.
Do I need to add this as new line or add it instead of my code I posted above? If yes, where do I add the allowed origins?
corsplug has inside the default this key:
expose: [],. Thought it is meant for Expose-Headers and I could somehow set my headers there.amnu3387
You just add them to the
plugline, as comma separated key-values. What I posted though is for the preflight to be approved when the client request contains extra headers such as “Bearer” and “X-File-Name”, I imagine the expose_headers would be to allow adding headers to the responseSardoan
Yes, headers to the response, that is what I want. I use JWT for authentification with bearer, works. My problem is the response, which returns
link,page_count… this get filters since it is not allowed asAccess-Control-Expose-Headersso I would like to add the headers scrivener header adds to the response. I can see the headers in the browser, butAccess-Control-Expose-Headersare empty in the browser, so it seems this blocks javascript from fetching the header keys and values from the response. I use the paging parameters in the get requests as get parameters (?page=1,page_size=20…) This works. But I need to fetch the headers with prev, next, last first, which I can not access atm within javascript, because not exposed in the response.Sardoan
Thanks,

I changed my code to
plug CORSPlug, origin: ~r/http:\/\/localhost:3333$|https:\/\/.*\.xxx$/, expose: ["link", "page-number", "per-page", "total", "total-pages"]Now I get the scrivener-header generated headers