最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

next.js - VPS sqlite issue on hostinger server - Stack Overflow

programmeradmin0浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论