This study describes the development of a novel numerical optimization framework to maximize the endurance of unmanned aerial vehicles (UAVs). We address the problem of numerically determining the optimal thrust and cruise angle of attack in a two-dimensional space for a UAV under certain initial, periodic, and bound constraints. The time horizon of the free final time optimal control problem (OCP) is first normalized, and the normalized OCP in integral form is discretized in physical space into a nonlinear programming problem (NLP) using Fourier collocation and quadrature based on equispaced points. Great attention in this work is placed on the accurate detection of jump discontinuities and resolving the thrust history effectively directly from the Fourier pseudospectral (FPS) data through a novel edge-detection method without any smoothing techniques. The numerical results demonstrate that the proposed method is simple, stable, and easy to implement.