The selfadjoint boundary layer problem, described by the second order linear differential equation is considered. The solution is presented as a sum of the reduced solution and layer solution which is approximated by the truncated orthogonal series where certain Legendre-type polynomials were used as the orthogonal basis. The layer solution is constructed upon the layer subinterval determined according to the asymptotic behavior of the exact solution by the use of apropriate resemblance function. This domain decomposition depends on the degree of chosen spectral approximation. The coefficients of the truncated orthogonal series are determined by the collocation method. The upper bound for the error function is constructed and the numerical example is included.