@@ -9,6 +9,7 @@ import { logger } from "../utils/logger.js";
99import { resolvePath } from "../utils/parseNameAndPath.js" ;
1010import { TriggerApi } from "../utils/triggerApi.js" ;
1111import dotenv from "dotenv" ;
12+ import fetch from "node-fetch" ;
1213
1314export const DevCommandOptionsSchema = z . object ( {
1415 port : z . coerce . number ( ) ,
@@ -48,7 +49,7 @@ export async function devCommand(path: string, anyOptions: any) {
4849 logger . success ( `✔️ [trigger.dev] Detected TriggerClient id: ${ endpointId } ` ) ;
4950
5051 // Read from .env.local or .env to get the TRIGGER_API_KEY and TRIGGER_API_URL
51- const { apiUrl, envFile } = await getTriggerApiDetails (
52+ const { apiUrl, envFile, apiKey } = await getTriggerApiDetails (
5253 resolvedPath ,
5354 options . envFile
5455 ) ;
@@ -59,9 +60,24 @@ export async function devCommand(path: string, anyOptions: any) {
5960 ` [trigger.dev] Looking for Next.js site on port ${ options . port } `
6061 ) ;
6162
63+ const localEndpointHandlerUrl = `http://localhost:${ options . port } ${ options . handlerPath } ` ;
64+
65+ try {
66+ await fetch ( localEndpointHandlerUrl , {
67+ method : "HEAD" ,
68+ headers : {
69+ "x-trigger-api-key" : apiKey ,
70+ "x-trigger-action" : "PING" ,
71+ "x-trigger-endpoint-id" : endpointId ,
72+ } ,
73+ } ) ;
74+ } catch ( err ) {
75+ logger . error ( `❌ [trigger.dev] No server found on port ${ options . port } .` ) ;
76+ process . exit ( 1 ) ;
77+ }
78+
6279 // Setup tunnel
6380 const endpointUrl = await resolveEndpointUrl ( apiUrl , options . port ) ;
64-
6581 const endpointHandlerUrl = `${ endpointUrl } ${ options . handlerPath } ` ;
6682
6783 const connectingSpinner = ora (
0 commit comments