CYCLIC ERROR: No response from server on port 3000 for nest.js app

442 views Asked by At

I'm trying to host nestjs rest api on cyclic and getting this error could not find anything about it

Here relevant package.json

 {
  "name": "server",
  "version": "0.0.1",
  "description": "",
  "author": "",
  "private": true,
  "license": "UNLICENSED",
  "scripts": {
    "build": "nest build",
    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
    "start": "node dist/main.ts",
    "start:dev": "npx nest start --watch",
    "start:debug": "npx nest start --debug",
    "start:prod": "node dist/main",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "jest",
    "test:watch": "jest --watch",
    "test:cov": "jest --coverage",
    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
    "test:e2e": "jest --config ./test/jest-e2e.json"
  },
  ........ 
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": "src",
    "testRegex": ".*\\.spec\\.ts$",
    "transform": {
      "^.+\\.(t|j)s$": "ts-jest"
    },
    "collectCoverageFrom": [
      "**/*.(t|j)s"
    ],
    "coverageDirectory": "../coverage",
    "testEnvironment": "node"
  },
  "engines": {
    "node": ">=14.0.0",
    "npm": ">=6.0.0"
  }
}

here is main.ts file

 import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { CorsOptions } from '@nestjs/common/interfaces/external/cors-options.interface';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  const corsOptions: CorsOptions = {
    origin: '*',
    methods: '*',
    credentials: true,
    optionsSuccessStatus: 204,
  };

  app.enableCors(corsOptions);

  await app.listen(process.env.PORT || 3000);
}

bootstrap();

I have hosted other project with same set up without any problem here the whole project link

I attempted to transfer the business logic into another project, but encountered issues. I tried setting the output route as both "/dist" and "/" on the cyclic dashboard. All the environmental variables are configured on Cyclic, and I removed the "env" entry from the gitignore. I built an app, pushed the pre-made "dist" file, and hardcoded the port to 5025, but it still returns a "3000" port not responding error.

0

There are 0 answers