adrianhajdin / project_ai_mern_image_generation Goto Github PK
View Code? Open in Web Editor NEWBuild and Deploy a Full Stack MERN AI Image Generation App MidJourney & DALL E Clone
Home Page: https://jsmastery.pro
Build and Deploy a Full Stack MERN AI Image Generation App MidJourney & DALL E Clone
Home Page: https://jsmastery.pro
I GOT GET http://127.0.0.1:5173/favicon.ico 404 (Not Found) problem, but the server shows UnhandledPromiseRejectionWarning problem.
Please somebody help to solve my problem, thanks.
(node:4048) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'data' of undefined
at file:///F:/projects/starlink/server/routes/dalleRoutes.js:34:45
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use node --trace-warnings ...
to show where the warning was created)
(node:4048) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:4048) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Error: connect ETIMEDOUT 64.13.192.74:443
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1148:16) {
errno: -4039,
code: 'ETIMEDOUT',
syscall: 'connect',
address: '64.13.192.74',
port: 443,
config: {
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
},
Hi there, When I run my app locally file saver working normally it download image to download folder. but I hosted website using netlify then when I click download button image opening in new tab what should I do?? please help
Hosted website
My Repo
Once I press 'Deploy Latest Commit' the deployment starts.
All goes well (Part1.png) until it tries to start the server which follows an error (Part2.png) that I do not know how to solve.
Edit: I would like to add that running the server in VS Code works perfectly. But not here on Render.
Feb 8 03:58:22 PM [nodemon] 2.0.20
Feb 8 03:58:22 PM [nodemon] to restart at any time, enter rs
Feb 8 03:58:22 PM [nodemon] watching path(s): .
Feb 8 03:58:22 PM [nodemon] watching extensions: js,mjs,json
Feb 8 03:58:22 PM [nodemon] starting node index index.js
Feb 8 03:58:24 PM internal/process/esm_loader.js:74
Feb 8 03:58:24 PM internalBinding('errors').triggerUncaughtException(
Feb 8 03:58:24 PM ^
Feb 8 03:58:24 PM
Feb 8 03:58:24 PM Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/render/project/src/server/mongodb/models/post.js' imported from /opt/render/project/src/server/routes/postRoutes.js
Feb 8 03:58:24 PM at finalizeResolution (internal/modules/esm/resolve.js:276:11)
Feb 8 03:58:24 PM at moduleResolve (internal/modules/esm/resolve.js:699:10)
Feb 8 03:58:24 PM at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:810:11)
Feb 8 03:58:24 PM at Loader.resolve (internal/modules/esm/loader.js:88:40)
Feb 8 03:58:24 PM at Loader.getModuleJob (internal/modules/esm/loader.js:241:28)
Feb 8 03:58:24 PM at ModuleWrap. (internal/modules/esm/module_job.js:56:40)
Feb 8 03:58:24 PM at link (internal/modules/esm/module_job.js:55:36) {
Feb 8 03:58:24 PM code: 'ERR_MODULE_NOT_FOUND'
Feb 8 03:58:24 PM }
Feb 8 03:58:24 PM [nodemon] app crashed - waiting for file changes before starting...
![Billing hard has been reached](https://user-images.githubusercontent.com/94656455/221067080-064c7df6-280e-49cb-98b1-219f5d6bacc6.PNG)
I guess these screenshots are self-explanatory anyone looking for a solution
Originally posted by @Taimur-s in #35 (comment)
VITE v4.0.4 ready in 407 ms
โ Local: http://localhost:5173/
โ Network: use --host to expose
โ press h to show help
Failed to resolve import "./assets/react.svg" from "src\App.jsx". Does the file exist?
1:53:32โฏp.m. [vite] Internal server error: Failed to resolve import "./assets/react.svg" from "src\App.jsx". Does the file exist?
Plugin: vite:import-analysis
File: C:/Users/Zach Non Admin/Desktop/dalle_clone/client/src/App.jsx:2:22
16 | var _s =
17 | import { useState } from "react";
18 | import reactLogo from "./assets/react.svg";
| ^
19 | import "./App.css";
20 | function App() {
at formatError (file:///C:/Users/Zach%20Non%20Admin/Desktop/dalle_clone/client/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:41235:46)
at TransformContext.error (file:///C:/Users/Zach%20Non%20Admin/Desktop/dalle_clone/client/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:41231:19)
at normalizeUrl (file:///C:/Users/Zach%20Non%20Admin/Desktop/dalle_clone/client/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:39540:33)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async TransformContext.transform (file:///C:/Users/Zach%20Non%20Admin/Desktop/dalle_clone/client/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:39673:47)
at async Object.transform (file:///C:/Users/Zach%20Non%20Admin/Desktop/dalle_clone/client/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:41506:30)
at async loadAndTransform (file:///C:/Users/Zach%20Non%20Admin/Desktop/dalle_clone/client/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:39313:29)
warn - The content
option in your Tailwind CSS configuration is missing or empty.
warn - Configure your content sources or your generated CSS will be missing styles.
warn - https://tailwindcss.com/docs/content-configuration
Then when I click on the server:
1:54:21โฏp.m. [vite] Internal server error: Failed to resolve import "./assets/react.svg" from "src\App.jsx". Does the file exist?
Plugin: vite:import-analysis
File: C:/Users/Zach Non Admin/Desktop/dalle_clone/client/src/App.jsx:2:22
16 | var _s =
17 | import { useState } from "react";
18 | import reactLogo from "./assets/react.svg";
| ^
19 | import "./App.css";
20 | function App() {
at formatError (file:///C:/Users/Zach%20Non%20Admin/Desktop/dalle_clone/client/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:41235:46)
at TransformContext.error (file:///C:/Users/Zach%20Non%20Admin/Desktop/dalle_clone/client/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:41231:19)
at normalizeUrl (file:///C:/Users/Zach%20Non%20Admin/Desktop/dalle_clone/client/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:39540:33)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async TransformContext.transform (file:///C:/Users/Zach%20Non%20Admin/Desktop/dalle_clone/client/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:39673:47)
at async Object.transform (file:///C:/Users/Zach%20Non%20Admin/Desktop/dalle_clone/client/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:41506:30)
at async loadAndTransform (file:///C:/Users/Zach%20Non%20Admin/Desktop/dalle_clone/client/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:39313:29) (x2)
pm ERR! Missing script: "start"
npm ERR!
npm ERR! Did you mean one of these?
npm ERR! npm star # Mark your favorite packages
npm ERR! npm stars # View packages marked as favorites
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\admin\AppData\Local\npm-cache_logs\2023-02-10T17_01_01_797Z-debug-0.log
This is the eroor
How to fix it?
error [email protected]: The engine "node" is incompatible with this module. Expected version ">=14.20.1". Got "14.17.0"
May 13 02:30:51 PM error Found incompatible module.
got this error while running the folder on Render
SyntaxError: Unexpected token 'B', "Billing ha"... is not valid JSON
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\Users*\Desktop\coding*\Dalle\server\routes\postRoutes.js' imported from C:\Users*\Desktop\coding***\Dalle\server\index.js
at new NodeError (node:internal/errors:400:5)
at finalizeResolution (node:internal/modules/esm/resolve:326:11)
at moduleResolve (node:internal/modules/esm/resolve:945:10)
at defaultResolve (node:internal/modules/esm/resolve:1153:11)
at nextResolve (node:internal/modules/esm/loader:163:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:842:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
at ModuleWrap. (node:internal/modules/esm/module_job:77:40)
at link (node:internal/modules/esm/module_job:76:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
Node.js v18.13.0
[nodemon] app crashed - waiting for file changes before starting...
does not figure out how to fix it :(
getting following error while fetching posts from the mongodb
it is showing error when i do response data to json format
at this part
if (response.status == 200) {
const result = await response.json();
setAllPosts(result.data.reverse());
}
successfully fetching posts from the mongodb when i do console.log(response)
Hello there!
I'm trying to commit the project to GitHub, but everytime I receive the mail fro openAI telling me that they rotated the key because it got exposed.
I already created the .gitignore file with .env, but it does not seems to work. I do not have the .env file in my repository https://github.com/tynoschuck/Ai-image-generator but I keep receiving the mail.
Any chande you know how to fix this? Thanks in advance!
can anyone tell me what this eerror is about. i have been solving since 12 hours yet have'nt find solution.
i have tried the fix available like setting up new cluster of mongodb and rechecking the code deeply please help cause it took me 4 hours to resolve this error but it isn't solved yet
MY create-post is rendering only a white page. I compared my code against the git source and I don't see what I'm missing.
As soon as I am inputting
const response = await fetch("https://dalle-arbb.onrender.com/api/v1/post", {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
});
I am getting a CORS error. How do I fix this?
I have seen a lot of comments regarding this issue. Here's the solution:
In your CreatePost.jsx file the
Change that line on the above image to this: const response = await fetch('http://localhost:8080/api/v1/dalle', {
The reasoning is of course the domain name
I had an error while opening http://localhost:8080/api/v1/dalle "Bartender API access denied." because it violates the following Content Security Policy directive: "default-src 'none'". Note that 'frame-src' was not explicitly set, so 'default-src' is used as a fallback.
Whenever I try to generate an image, I get an alert error (TypeError: Failed to fetch) and an error in the console log (POST https://localhost:8080/api/v1/dalle net::ERR_SSL_PROTOCOL_ERROR). I know that both of these are for my generatingImg function.
const generateImage = async () => {
if (form.prompt) {
try {
setGeneratingImg(true);
const response = await fetch('https://localhost:8080/api/v1/dalle', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
prompt: form.prompt,
}),
});
console.log(response)
const data = await response.json();
setForm({ ...form, photo: `data:image/jpeg;base64,${data.photo}` });
} catch (err) {
alert(err);
} finally {
setGeneratingImg(false);
}
} else {
alert('Please provide proper prompt');
}
};
I was able to generate images before but not render them on the home page after sharing, so I searched a bit and made some middleware changes to allow that. However, that seemed to break my code so I went back to the original place where the images were at least generating. But, as you can see, even that is not happening now. Since a lot of your comments on the video suggested it may have something to do with the API key, I've replaced mine with a new one too.
Here's my GitHub code: https://github.com/AnukratiMehta/image-generation.git
Please let me know how I can fix this issue. TIA!
ERROR ON BACKEND TERMINAL -----
[nodemon] 2.0.22
[nodemon] to restart at any time, enter rs
[nodemon] watching path(s): .
[nodemon] watching extensions: js,mjs,json
[nodemon] starting node index index.js
Server has started on port http://localhost:8080
connected to mongodb Database
Error: connect ETIMEDOUT 104.18.7.192:443
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
errno: -4039,
code: 'ETIMEDOUT',
syscall: 'connect',
address: '104.18.7.192',
port: 443,
config: {
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
},
adapter: [Function: httpAdapter],
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
validateStatus: [Function: validateStatus],
headers: {
Accept: 'application/json, text/plain, /',
'Content-Type': 'application/json',
'User-Agent': 'OpenAI/NodeJS/3.2.1',
Authorization: 'Bearer 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',
'Content-Length': 73
},
method: 'post',
data: '{"prompt":"beach ","n":1,"size":"1024x1024","response_format":"b64_json"}',
url: 'https://api.openai.com/v1/images/generations'
},
request: <ref *1> Writable {
_writableState: WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
destroyed: false,
decodeStrings: true,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: true,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
afterWriteTickInfo: null,
buffered: [],
bufferedIndex: 0,
allBuffers: true,
allNoop: true,
pendingcb: 0,
prefinished: false,
errorEmitted: false,
emitClose: true,
autoDestroy: true,
errored: null,
closed: false
},
_events: [Object: null prototype] {
response: [Function: handleResponse],
error: [Function: handleRequestError],
socket: [Function: handleRequestSocket]
},
_eventsCount: 3,
_maxListeners: undefined,
_options: {
maxRedirects: 21,
maxBodyLength: 10485760,
protocol: 'https:',
path: '/v1/images/generations',
method: 'POST',
headers: [Object],
agent: undefined,
agents: [Object],
auth: undefined,
hostname: 'api.openai.com',
port: null,
nativeProtocols: [Object],
pathname: '/v1/images/generations'
},
_ended: false,
_ending: true,
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 73,
_requestBodyBuffers: [ [Object] ],
_onNativeResponse: [Function (anonymous)],
_currentRequest: ClientRequest {
_events: [Object: null prototype],
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: null,
_hasBody: true,
_trailer: '',
finished: false,
_headerSent: true,
socket: [TLSSocket],
_header: 'POST /v1/images/generations HTTP/1.1\r\n' +
'Accept: application/json, text/plain, /\r\n' +
'Content-Type: application/json\r\n' +
'User-Agent: OpenAI/NodeJS/3.2.1\r\n' +
'Authorization: Bearer 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\r\n' +
'Content-Length: 73\r\n' +
'Host: api.openai.com\r\n' +
'Connection: close\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: noopPendingOutput],
agent: [Agent],
socketPath: undefined,
method: 'POST',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
path: '/v1/images/generations',
_ended: false,
res: null,
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'api.openai.com',
protocol: 'https:',
_redirectable: [Circular *1],
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype]
},
_currentUrl: 'https://api.openai.com/v1/images/generations',
[Symbol(kCapture)]: false
},
response: undefined,
isAxiosError: true,
toJSON: [Function: toJSON]
}
####################################################################
I'm able to fetch image from openAi but when i click on share with community button
getting this error on backend and on console
latest image doent display in this page
##################################
PLEASE HELP ME TO RESOLVE THIS
I got stuck at share with community point . JSM sir I follow this whole tutorial but after click surprise me then generating photo but when I click on share it community button then I am come back to home page with a only loading not photo is add to the community. And that loader is continues loading and loading .pls help me sir .
I can't move onto further steps because of this issue, someone please resolve this..
dalleRoutes.js
import express from 'express';
import * as dotenv from 'dotenv';
import { Configuration, OpenAIApi } from 'openai';
dotenv.config();
const router = express.Router();
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
router.route('/').get((req, res) => {
res.send('Hello from DALL-E!' );
});
router.route('/').post(async (req, res) => {
try {
const { prompt } = req.body;
const aiResponse = await openai.createImage({
prompt,
n: 1,
size: '1024x1024',
response_format: 'b64_json'
});
const image = aiResponse.data.data[0].b64_json;
res.status(200).json({ photo: image });
} catch (error) {
console.error(error);
res.status(500).send(error?.response.data.error.message);
}
});
export default router;
CreatePost.jsx
const generateImage = async () => {
if (form.prompt) {
try {
setGeneratingImg(true);
const response = await fetch('http://localhost:8080/api/v1/dalle', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
prompt: form.prompt,
}),
})
const data = await response.json();
setForm({ ...form, photo: `data:image/jpeg;base64,${data.photo}` })
} catch (error) {
alert(error);
} finally {
setGeneratingImg(false);
}
} else {
alert('Please provide proper prompt')
}
}
hello everyone.
I face issues posting new images on community pages when I use baseURL = "https://dall-e-brtd.onrender.com" but when I use baseURL = "http://localhost:8080" all website functions work well.
so when using this URL to post API calls I got this error {"success": false, "message": "Unable to create a post, please try again"}
I completed the youtube tutorial step by step understanding and do the same things done in the tutorial but my home page where the posts are I have uploaded on cloudinary are not getting fetched and always says no posts exist. please help me solve the problem.
Here is the link to my repo: https://github.com/Bibhavshah/Dalle_Ai
I get this when I try to generate an image. how do I fix this? I am using the right APIs and I checked the code more than once and there is no typos and errors. Any help is appreciated, thanks.
The dotenv (.env) file isn't working for me, it always shows the string is undefined.
Since we are not storing the images along with its relevant data in the MongoDB Atlas instance and instead storing them using the cloudinary service, isn't the connection to the MongoDB instance redundant as cloudinary acts as the database in this case?
what kind of error it? any solutionsss....
hello guys, i tried to create an image and i got this error
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
what should i do
I have tried the above solution provided earlier but still, it is showing the same error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.