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
37 Replies
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
oh yeah response.json is going to be a function
ok so the backend should never return anything BUT json
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
these are on different ports yeah?
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
i mean
http://localhost:8080
vs http://localhost:8081
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
ah
so that's one problem
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
you're making the request in your frontend, to your front end server
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
says fetch from the same origin i'm on
/payment_intents/${paymentIntent.id}/capture
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
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
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
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
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
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 htmlUnknown User•4y ago
Message Not Public
Sign In & Join Server To View
what did you change it do?
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
ah ok
then yeah that MAY be getting a CORS error
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
i don't know if cloudfunctions would let you change the cors headers
but possibly
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
the browser is telling you it's a cors issue
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
are they going to the same place?
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
on the same cloudfunction? or different ones?
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
hrmm. i don't know a ton about cloudfunctions is it similar to lambda on aws?
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
ah ok. so what's in that file?
are you applying the cors headers to everything?
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
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?
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View