Next.js Discord

Discord Forum

public folder not working

Unanswered
Polar bear posted this in #help-forum
Open in Discord
Polar bearOP
Hi Folks,

I am facing a strange issue while serving assets from the "public" folder

None of the assets are getting loaded and throws 404.

It's located at the root of the project.

I have server.js which is hydrating the HTML before serving.

What could be the possible issue here?

14 Replies

try restarting the dev server
and trying it in local production
Polar bearOP
I did numerous times , not helping
what's in your public folder
that you're trying to use
Polar bearOP
All images
Fonts
Greenish Elaenia
does importing assets from outside /public work?
how are you importing the assets into your page? lets check your syntax first.

import soundIcon from '../assets/icons/sound.png'
This worked for me for loading assets from outside of public

try and see if the same syntax works for the public folder
Polar bearOP
Basically all my components built in stencil js and reference with /
Initially i thought it could be permission issue but its not

Let me try what you suggested
Greenish Elaenia
note, when you try my suggestion, they import as objects.
so your syntax needs a ".src" to get their path
Like so;
<Image src={soundIcon.src}></Image>
I referenced from this repo.
@Greenish Elaenia note, when you try my suggestion, they import as objects. so your syntax needs a ".src" to get their path Like so; <Image src={soundIcon.src}></Image>
Polar bearOP
It would be a huge task to update all instances and moreover wont work with stencil