according to chess rules castling can be done only if the king does not cross over or end on a square in which it would be in check. this rule is not supported in chess.com
you can castle if these requirements are met-
1 you have no pieces between the king and the rook
2 your King and the rook has never moved from it's starting position
3 you are not currently being in check nor passing through check
according to chess rules castling can be done only if the king does not cross over or end on a square in which it would be in check. this rule is not supported in chess.com