Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work with images created at runtime #75

Open
flyotlin opened this issue Aug 15, 2021 · 0 comments
Open

Does not work with images created at runtime #75

flyotlin opened this issue Aug 15, 2021 · 0 comments

Comments

@flyotlin
Copy link

I have a Next.js app with CMS that can upload images, save images locally, and then display images on Next.js again.

I found that Next.js does not show images created at runtime, only images that exist at build time. So I tried this module.
static file serving

I first set up next.config.js like this:

const withTM = require("next-transpile-modules")(["@fullcalendar"])
const withImages = require("next-images")

module.exports = withImages(
    withTM({
        async rewrites() {
            return [
                {
                    source: "/api/:slug*",
                    destination: "http://golang:5000/api/:slug*",
                },
            ]
        },
    })
)

then I try to show my images with absolute url like this:

<img
   className="d-block w-100"
   src={require("/src/static" + url)}
/>

But it turns out not working, and shows An unexpected error has occurred..

Does anyone has any idea on why it does not work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant