I want to execute a script from the public directory. However, no matter how I pass the src to , it returns 404 error, indicating that the file does not exist, although the file exists in the public directory.
Here is a very simple example:
const Home: NextPage = async () => {
return (
<>
<Script src="/static/example.js" />
<HomePage />
</>
);
};
export default Home;
Does anyone know how to handle this issue? I am using next version 13.5.3
try to wrap the Script component with
Head
component from"next/document"