APL (dzaima/APL), 20 bytes
⊢⌿⍥,⍨1∊ ̈⍳∘⍴∊ ̈ ̈∘⊂1, ̈⍴
⍴ shape (length along each dimension) of the array
1, ̈ prepend 1 to each
...∊ ̈ ̈∘⊂ for each of each of the following, is it a member of the corresponding element of that?
⍳∘⍴ the indices of an array of the shape of the argument
1∊ ̈ for each of those, is 1 a member?
...⌿⍥,⍨ use that flattened, to filter the flattened...
⊢ argument
APL (dzaima/APL), 20 bytes
⊢⌿⍥,⍨1∊ ̈⍳∘⍴∊ ̈ ̈∘⊂1, ̈⍴
⍴ shape (length along each dimension) of the array
1, ̈ prepend 1 to each
...∊ ̈ ̈∘⊂ for each of each of the following, is it a member of the corresponding element of that?
⍳∘⍴ the indices of an array of the shape of the argument
1∊ ̈ for each of those, is 1 a member?
...⌿⍥,⍨ use that flattened, to filter the flattened...
⊢ argument