  Moir\'e structures are receiving increasing attention in nanophotonics as
they support intriguing optical phenomena. In the so-called "magic
configuration", one-dimensional moir\'es give rise to fully dispersionless
energy bands known as "flatbands", where the light is tightly localized within
each supercell of the periodic moir\'e. The goal of this investigation is to
determine to what extent the confinement of light, observed in periodic
structures, is preserved in microcavities of finite size. Here we analyze the
optical response of finite moir\'e structures consisting of one, two, or more
supercells of 1D moir\'e. Our calculations reveal that for single-supercell
cavity, the magic configuration does not impact the electric field confinement
at the wavelength of the flat band modes. However, when three or more
supercells are connected, we show that the coupling between supercells is
canceled at the "magic configuration", resulting in highly confined modes with
a quality factor greater than $10^6$ and exhibiting the characteristics of a
quasi-bound state in the continuum where optical losses are eliminated through
a destructive interference process.
