Getting HTML 200 from fetch instead of JSON

did you request json from the backend? not sure if it expects to be told what to return
UU
Unknown User864d ago
G
ghardin137864d ago
oh yeah response.json is going to be a function ok so the backend should never return anything BUT json
UU
Unknown User864d ago
G
ghardin137864d ago
these are on different ports yeah?
UU
Unknown User864d ago
G
ghardin137864d ago
i mean http://localhost:8080 vs http://localhost:8081
UU
Unknown User864d ago
G
ghardin137864d ago
ah so that's one problem
UU
Unknown User864d ago
G
ghardin137864d ago
you're making the request in your frontend, to your front end server
UU
Unknown User864d ago
G
ghardin137864d ago
fetch(`/payment_intents/${paymentIntent.id}/capture`, {
fetch(`/payment_intents/${paymentIntent.id}/capture`, {
says fetch from the same origin i'm on /payment_intents/${paymentIntent.id}/capture
UU
Unknown User864d ago
G
ghardin137864d ago
it doesn't know that your backend is on a different server it only knows what you told it so you'd either want to tell it that and deal with CORS or you'd set up proxying
UU
Unknown User864d ago
G
ghardin137864d ago
well right now it's not it's just giving you the html that would kickstart your front end because it doesn't know what to do with that path
UU
Unknown User864d ago
G
ghardin137864d ago
no absolutely not you're making a request to http://localhost:8080/payment_intents/${paymentIntent.id}/capture your front end server has no idea what to do with that so it's just serving up the base html
UU
Unknown User864d ago
G
ghardin137864d ago
what did you change it do?
UU
Unknown User864d ago
G
ghardin137864d ago
ah ok then yeah that MAY be getting a CORS error
UU
Unknown User864d ago
G
ghardin137864d ago
i don't know if cloudfunctions would let you change the cors headers but possibly
UU
Unknown User864d ago
G
ghardin137864d ago
the browser is telling you it's a cors issue
UU
Unknown User864d ago
G
ghardin137864d ago
are they going to the same place?
UU
Unknown User864d ago
G
ghardin137864d ago
on the same cloudfunction? or different ones?
UU
Unknown User864d ago
G
ghardin137864d ago
hrmm. i don't know a ton about cloudfunctions is it similar to lambda on aws?
UU
Unknown User864d ago
G
ghardin137864d ago
ah ok. so what's in that file? are you applying the cors headers to everything?
UU
Unknown User864d ago
G
ghardin137864d ago
hrmm yeah that ought to work if you open up the network devtools and find the request that isn't working what do you see in the request headers and response headers sections?
UU
Unknown User864d ago