#Ryan_Whipple - Portal Redirect
1 messages ยท Page 1 of 1 (latest)
Hello again! It sounds like you're trying to load the endpoint that redirects to the portal using JavaScript (like with fetch() or similar) instead of sending the person to that URL.
Does that make sense?
Hello! That's definitely possible. I changed the template form from HTML to a React component and made the endpoint on the right with a hard-coded customer for now.
Yeah, you don't want to use axios.post with that URL, you want to send the person to it.
gotcha. I figured axios.post would be equivalent to form method="POST" in this instance but I can see why that isn't the case
Yeah, they're pretty different in a situation like this. ๐
alright, then this may be a really embarrassing question, but if I just go back to the regular <form> template, I get this error message: Cannot POST /create-customer-portal-session
and that's with the server-side code taken right out of the docs
What does your server's code look like that defines the route?
Oh, it's in your screenshot.
Hang on...
Does it work without those CORS options in there?
If not, is there any further detail about that error? Are you seeing that in the browser console or server side?
removing CORS options doesn't change anything. That error message pops up in the browser main window, nothing comes back in either console
What's the URL in the browser when that's displayed? Is it your /create-customer-portal-session URL?
Any further detail in your server logs?
my React app is running on 3000, the server is 4000
Wait... what?
If you're running the server on a different port it sounds like you didn't specify that port in the URL you're posting to?
You need to post to http://localhost:4000/create-customer-portal-session but it sounds like you might be posting to a relative URL like /create-customer-portal-session instead, which would inherit the origin (including the port) of your React app.
๐คฆโโ๏ธ
I knew the URL in the browser should have been 4000. I did it in the axios request, but not the form
it works now
Awesome! ๐
lol, thanks a bunch! I really appreciate your help. I'm 2 months out of a coding bootcamp and working on projects with other alums, trying to get some real-world experience. Helping this guy set up his site is my first time working with Stripe. Seems like a good skillset to have since it's everywhere
Absolutely! This stuff can be tricky, and the error you made is common even among experienced developers. ๐