Currently, I'm developing a multiplayer .io-style game that utilizes both Socket.io and SvelteKit. While testing the project on a local development server, everything runs smoothly. However, upon deploying to Vercel, an error message stating
Failed to load resource: the server responded with a status of 404 ()
is logged.
Below is my current express server.ts code snippet (not functional)
import http from "HTTP";
import { handler } from './build/handler.js';
// Encounters an error: An import path cannot end with a '.ts' extension.
import injectSocketIO from "src/lib/socket-handler.ts";
import express from 'express';
const app = express();
const server = http.createServer(app);
injectSocketIO(server)
app.use(handler);
// Is there something that needs to be modified here?
server.listen(3000, () => {
console.log('Running on http://localhost:3000');
});
To run a local development server using the vite plugin, I input the following:
import injectSocketIO from "./src/lib/socket-handler";
plugins: [sveltekit(), {
name: "sveltekit-socket-io",
configureServer(server) {
injectSocketIO(server.httpServer);
},
}],
I have attempted to follow the guidelines provided here. However, I am using socket-handler.ts
instead of socket-handler.js
and am unsure about how to establish a startup script for execution with Vercel. Any assistance on this matter would be greatly appreciated!