The global non-modal stability of the flow in a right-angled streamwise corner is investigated. Spatially confined linear optimal initial conditions and responses are obtained by use of direct-adjoint looping. Two base states are considered, the classical self-similar solution for a zero streamwise pressure gradient, and a modified solution that mimics leading-edge effects commonly observed in experimental studies. The latter solution is obtained in a reverse engineering fashion from published measurement data. Prior to the global analysis, a classical local linear stability and sensitivity analysis of both base states is conducted. It is found that the base-flow modification drastically reduces the critical Reynolds number through an inviscid mechanism, the so-called corner mode. A survey of the geometry of the two base states confirms that the modification greatly aggravates the inflectional nature of the flow. Global optimals are calculated for subcritical and supercritical Reynolds numbers, and for two finite optimization times. The optimal initial conditions are found to be self-confined in the spanwise directions, and symmetric with respect to the corner bisector. They evolve into streaks or streamwise modulated wavepackets, depending on the base state. Substantial transient growth caused by the Orr mechanism and the lift-up effect is observed.