openai-quickstart-node
openai-quickstart-node copied to clipboard
Internal Server Error
I am running the project locally but whenever I tried clicking "Generate names" but it shows this error. Anyone knows how to fix this?
I'm getting exactly the same thing... did you get anywhere with your issue @Sheikh-JamirAlam
Seems like my quota has exceeded for making request to the API. No idea how to work around it though. @kwello-alexhicks
My issue doesn't appear to be related to the API, reviewing the generate Response is the same as yours that it is not a valid JSON reponse
{ "props": { "pageProps": { "statusCode": 500 } }, "page": "/_error", "query": { "__NEXT_PAGE": "/api/generate" }, "buildId": "development", "isFallback": false, "err": { "name": "Error", "message": "Request failed with status code 401", "stack": "Error: Request failed with status code 401\n at createError (/Users/XXXXX/openai-quickstart-node/node_modules/axios/lib/core/createError.js:16:15)\n at settle (/Users/XXXXX/openai-quickstart-node/node_modules/axios/lib/core/settle.js:17:12)\n at IncomingMessage.handleStreamEnd (/Users/XXXXX/openai-quickstart-node/node_modules/axios/lib/adapters/http.js:322:11)\n at IncomingMessage.emit (node:events:525:35)\n at IncomingMessage.emit (node:domain:489:12)\n at endReadableNT (node:internal/streams/readable:1359:12)\n at process.processTicksAndRejections (node:internal/process/task_queues:82:21)" }, "gip": true, "scriptLoader": [] }
@Sheikh-JamirAlam Ok, so i opened a new terminal, ran
npm run build
npm run start
npm run dev
Then I can successfully run the application on new port 3001
Bit odd, or missing step in the documentation?
Yes the API is not generating a JSON file. Do you run the "npm run start" and "npm run dev" commands in different terminals? @kwello-alexhicks
@Sheikh-JamirAlam correct order, from the same terminal (after killing the faulty terminal) is:
npm run start npm run build npm run dev
This now works successfully for me
@kwello-alexhicks Now I am facing with this error. I ran npm run build and it still is the same. Can you show your terminal if thats ok?
Here is a clue whats going on:
response: { status: 401, statusText: 'Unauthorized', headers: { date: 'Mon, 12 Dec 2022 19:14:53 GMT', 'content-type': 'application/json; charset=utf-8', 'content-length': '475', connection: 'close', vary: 'Origin', 'x-request-id': '670473a8d453eedfefc8f0d9e3cc6c32', 'strict-transport-security': 'max-age=15724800; includeSubDomains' },
@ Sheikh-JamirAlam: Took me a while but my similar issue of errors was that I put my API Key in ".env.example" when it of course needed to be in ".env" instead.
same situation, thx
same situation, thx
Thanks. Did the same mistake. Added the .env file with API key fixed the issue.
@Sanan4li Can you tell me which commands you are using to run it locally?

I'm still getting the issue even after running:
npm run start npm run build npm run dev
@kwello-alexhicks is this still working on your end?
@Sheikh-JamirAlam are you still having trouble?
@jeevnayak @schnerd would either of you happen to know any fixes for this perchance?
![]()
I'm still getting the issue even after running:
npm run start npm run build npm run dev
@kwello-alexhicks is this still working on your end?
@Sheikh-JamirAlam are you still having trouble?
no need to use command line, just check your env filename, the repo's original env filename is ".env.example", rename it with ".env" will work : )
@AlbaChloe ive already done that, but no dice. Seems the 500 errors coming from elsewhere
@neocybereth Yeah same, its not because of the .env file. As the error shows the API is returning a HTML file which was supposed to be a json. @AlbaChloe Is it working for you locally?
@Sheikh-JamirAlam yep, my local file works fine after I change the filename to ".env", and before that, I got the same error
@neocybereth sorry, maybe elsewhere I don't know, hope others can help you
@AlbaChloe Did you maybe change the dependency versions or it worked just like that?
@Sheikh-JamirAlam nope, I've never changed the dependencies, just run "npm install" to install the requirements
I added some error handling logic (see #30) which should surface error messages returned by the API or due to misconfigured environment variables.
@neocybereth want to pull the latest version and give it a try?
Yup, will do that now!

Welp seems that did the trick now @schnerd ..thank you!
👍
I'm going to close this issue for now – the frontend should be surfacing more detailed error messages. If anyone continues to see errors where it's unclear how to resolve them, please feel free to open a separate issue!