undefined if startOrigin has no port to start scanning from.
import {
HttpMethod,
HttpStatus,
defineApi,
defineEndpoint,
findDevServerPort,
} from '@rest-vir/api';
const myApi = defineApi({
apiName: 'my-api',
endpoints: [
defineEndpoint({
path: '/my-path',
requests: {
[HttpMethod.Get]: {
responses: {
[HttpStatus.Ok]: {
responseData: undefined,
},
},
},
},
}),
],
webSockets: [],
});
const {origin} = await findDevServerPort(myApi, {
startOrigin: 'https://localhost:3000',
});
Use this to find an api's port number when its server was started without a locked-in port. The client (usually a website frontend) scans upward from the port in
startOrigin, sending anOPTIONSrequest to the api's first endpoint until one responds with a matching restVirApiNameHeader.Note that the api given must have at least one endpoint defined for this function to work.