admin 管理员组文章数量: 1087134
I am writing webapplication in Next.js, Drizzle-orm, sqlite and tested it on local machine, its working without any issues but when I move to hostinger VPS server its not working.
It gives 500 error.
import { NextResponse } from 'next/server';
import { db } from '@/lib/db/client';
import { posts } from '@/lib/db/schema';
export async function GET() {
try {
const postList = await db.select().from(posts).orderBy(posts.id);
return NextResponse.json(
{ posts: postList },
{ status: 200 }
);
} catch (error) {
console.error('Error fetching posts:', error);
return NextResponse.json({ error: 'Failed to fetch posts' }, { status: 500 });
}
}
import { useCallback, useState } from 'react';
import { toast } from 'sonner';
export default function usePosts() {
const [posts, setPosts] = useState<any[]>([]);
const fetchPosts = useCallback(async () => {
try {
const response = await fetch('/api/test');
if (!response.ok) throw new Error('Failed to fetch posts');
const data = await response.json();
setPosts(data.posts);
} catch (error) {
toast.error('Error fetching posts');
console.error(error);
}
}, []);
return { posts, fetchPosts };
}
Hostinger says its your Server, so I am lost.
本文标签: nextjsVPS sqlite issue on hostinger serverStack Overflow
版权声明:本文标题:next.js - VPS sqlite issue on hostinger server - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744062285a2526941.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论