-
I am making a blog like dev.to where most of the stuff is dynamic especially images. The WYSIWYG editor uploads the images through "/api/" based route to the "public" folder. Now , in dev mode, when i upload the image, its fine, accessible but then when i run the app after building it using However, now after uploading the image, if i then rebuild my app, i can then access the image. Is this normal ? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 6 replies
-
The |
Beta Was this translation helpful? Give feedback.
-
Trying to do this but no luck. Any thoughts? import { NextApiResponse, NextApiRequest } from 'next';
export default async (req: NextApiRequest, res: NextApiResponse) => {
try {
const url = req.query.url;
const response = await fetch(decodeURIComponent(url as string));
const r = await response.text();
res.setHeader('Content-Type', response.headers.get('content-type'));
res.setHeader('Content-Disposition', 'inline');
// res.setHeader('Content-Transfer-Encoding', 'base64');
res.send(Buffer.from(r));
} catch (e) {
res.status(500).json({ error: e });
}
}; |
Beta Was this translation helpful? Give feedback.
-
@dukesx Did you find a solution? |
Beta Was this translation helpful? Give feedback.
-
did any one find the solution ? |
Beta Was this translation helpful? Give feedback.
-
I found a solution about this. I changed next/Image to img to dynamically upload images from users and added a server.js filename in the root directory (not in the app). I saved the images in public/uploads/[folder-day]/[imageUploadedFromUser]. I am using Next.js 14 this is my code for server .js
then i modify package.json scripts start like this
|
Beta Was this translation helpful? Give feedback.
The
public
folder is only used to store static content, and not dynamic content. That's why when you rebuild the files will be available.