https://pulumi.com logo
#general
Title
# general
s

strong-belgium-23055

05/04/2019, 12:57 PM
Hello, I have a stupid question and I’m not sure it is directly linked to Pulumi, but I’m sure you must have faced simiral issues 😄. I have a project with an API created by API from pulumi/cloud-aws. At the beginning everything was fine, I could get Json responses to my call. But now I face CORS issues, so I tried to solve it by adding headers to my all my responses, and returning 204 to every call OPTIONS (It’s not great but I’m just trying to make things work for a small PoC) Now every route seems fine, I don’t have the same issues as before, but all my responses body are Json, base 64 encoded 🙃. Do you know why it that and how could I go back to a state of having Json body as responses ? I always use Response.status().json(myObject) in my controllers The headers I added are the following : ‘Access-Control-Allow-Origin’ -> ‘*’ ‘Access-Control-Allow-Headers’ -> ‘Origin, X-Requested-With, Content-Type, Accept, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, Cache-Control, Access-Control-Request-Headers, devToken, email’ ‘Access-Control-Allow-Methods’ -> ‘POST, GET, OPTIONS, PUT, DELETE’
c

colossal-beach-47527

05/04/2019, 3:17 PM
I can’t say for sure, but if you are getting a behavior change in the way the content is being served from your endpoint. Then I would guess it has something to do with you adding those new response headers. Perhaps there was some header being added by default, that is no longer sent because you customized it? If the content was previously served as JSON, but now comes across as base-64 encoded text. Perhaps you need to explicitly set the
Content-Type
header? in the response? There are many moving parts that could also be the culprit here. But hopefully that helps.
s

strong-belgium-23055

05/04/2019, 5:24 PM
Thank you for your response, I noticed that the content from my GET/POST/... calls was served in JSON again when I removed the OPTIONS endpoints and keept the headesr I set. So I compared the headers I get when there is this endpoint in my api and when there is not, and as expected in both cases the headers are the same (and both have Content-Type set to application/json, even when the body is in base 64). So now I don’t really know why the addition of a new endpoint could change the way the others are serving data 🤔