#React App

59 messages · Page 1 of 1 (latest)

hard yoke
#

Nah, it would need to be wherever your node code is hosted. It doesn't seem to be there. Do you have something along the lines of:

app.post('/endpoint1', async (req, res) => {
  res.set('Content-Type', 'application/json');

  res.send(outputString);
  

in your code?

torn panther
#

no-

#

hold on

hard yoke
#

ah so that's all together with your code for the website? sorry I don't know how to make that work

#

I've usually split out that index file into it's own project and then used that as the backend

torn panther
#

I mean I have that and the app.js but yeah

#

the app.js is frontend

hard yoke
#

but they're both up on netlify

torn panther
#

the index is backend

#

uhhhhh

#

Idk how to confirm or deny that lol

still hollow
#

Dunno if it'd be helpful, but the project I've been working on automatically builds a proxy in next.js apps so you don't have to ship your OpenAI API key to the browser. 9 min coding screencast that shows it off here: https://www.loom.com/share/b367f4863fe843998270121131ae04d9

This coding screencast shows how we can use Imaginary Programming to easily add delightful, intelligent features to an existing web app by just defining function prototypes for the new features we want, without any implementation.

Find a live version of the site we describe here: https://blog-demo.imaginary.dev/
Find the code for the demo site ...

▶ Play video
torn panther
#

ill have a look

torn panther
hard yoke
#

that's the idea but only if that address goes to your node endpoint - which I'm not sure about

still hollow
# torn panther does not seem to load

The video isn't loading? That's very strange; it loads perfectly fine for me. There's also info at imaginary.dev and install info at imaginary.dev/docs

hard yoke
#

sorry that's beyond my abilities

#

Video loads for me -looks neat!

torn panther
#

its cool tho

still hollow
#

Did you make a backend API?

torn panther
# still hollow I think this looks like client-side code that is calling a backend API, which pr...

Want to build your own ChatGPT or learn the advanced ways to use Chat GPT? This video will be a more advance tutorial about OpenAI and its AI models, how to do prompts, generate content, and finally build an application based on its API.

⭐ Try the OpenAI Template - Starter Kit I've made ⭐
https://enhanceui.gumroad.com/l/chatgpt-starter-template...

▶ Play video
#

that is the tutorial I followed if u want to take a look

torn panther
still hollow
#

yep, that's a backend API!

#

it looks like you are calling the backend API on a server out on the internet called promptenhancer.xyz. Have you deployed your backend API there?

torn panther
#

I used npm run build. then I moved the build file to my webhosting service which is netlify

#

thanks for the continued help by the way

torn panther
still hollow
#

So, you should try POSTing something to that URL and seeing if you get a response to verify if it is working. You do have to set netlify up to use Netlify Functions if you want dynamic code to work

#

Though if it's a node.js project, that should work without much config

#

I'm a little confused if you are doing this locally or not. If you are developing locally, it makes more sense to go against the backend api running on your local machine so you can change the code and see the changes without redeploying

torn panther
#

should I rather tell you what I wanted it to do as an end goal?

#

what I wanted to happen was, a user would open the website, type their prompt in and click a submit button. Then a output would pop up on the screen which has a longer version of their prompt(this being done with openai davinci-003.

#

im sorry I could probably explain/understand better on a call or something

torn panther
#

if that makes sense

still hollow
#

So usually we develop and test websites locally so that we can rapidly change the code and see the differences that we make. Then when the code is in a state we like, we deploy it out to the world

#

So eventually, yes, you don't want the code to be running locally on your laptop, because no one can point a browser at your laptop

#

But while you are working on it, usually you want it to be on your machine. Then, when you like what you've built, you put it out into the world.

#

But you definitely need both a frontend and backend because of how OpenAI API keys work

torn panther
#

ok so I like what ive built and I want it in the world

torn panther
#

this is what I want, to get it off of my local and on the webhost where it is deployed

still hollow
#

Well, you have to test to see if what you did worked. If it worked, you should be able to POST information to the backend API endpoint that you deployed

#

Look up "how to POST json to an API endpoint" to see how to test if what you've deployed works

torn panther
#

Do I deploy that alone?

#

I deployed it and it says error404

#

chat gpt says if I want to change my endpoint I should use url instead of port

#

To change the endpoint to https://www.promptenhancer.xyz/, you just need to replace port with url in the app.listen() method, like this:

javascript
Copy code
app.listen(url, () => {
console.log(Example app listening)
});
Make sure that url variable is properly defined and holds the correct URL value.

torn panther
still hollow
#

I'm sorry, I can't really spend more time on this, gotta do my job 🙂 . I'd recommend reading up on deploying node backends; I suspect that something about your config is wrong