i got some problem on next.js 15.0.3, node.js 20.15.0 and rocky linux 9.4 (Blue Onyx)
i was trying to navigate to a specific page through the tag.
but i got error.
[TypeError: fetch failed] {
cause: [ConnectTimeoutError: Connect Timeout Error] {
name: 'ConnectTimeoutError',
code: 'UND_ERR_CONNECT_TIMEOUT',
message: 'Connect Timeout Error'
}
}
this component is client compoenet i try to reached.
'use client'
//...
export const dynamic = 'force-dynamic';
//...
export default function Component() {
const fileRef = useRef<HTMLInputElement>(null);
const [ file, setFile ] = useState<File>();
//...
const router = useRouter();
//...
const onSave = async () => {
const formData = new FormData();
if(file) {
//...
formData.append('file', file);
//...
} else {
alert('error');
return false;
}
try {
const result = await fetch(UPLOAD, {
method: 'POST',
body: formData,
credentials: 'include',
}).then(res => res.json());
if(result.success) {
router.push(`/path/${result.file_id}`);
} else {
alert('error');
}
} catch(e) {
console.error(e);
alert('error');
}
};
//...
return <div>
//...
<div>file: <input ref={fileRef} type="file" accept="image/*" onChange={onFileChange} /></div>
<button onClick={onSave}>commit</button>
//...
</div>;
}
it load the page very slowly at first time.
but load success then become a normally;
i don’t know what is problem.
strangely it works in my computer(next.js 15.0.3, node.js 20.15.0, MacOS).