I suggest you look at my replies in the comments to your post for more details, but here, I just aim to explain what is an appropriate method for utilizing substitution to obtain the correct value for the integral. Notice that $$\int_0^{\frac{2\pi}3}\frac{\cos(x)}{1+\sin(x)}\,\mathrm{d}x=\int_0^{\frac{\pi}2}\frac{\cos(x)}{1+\sin(x)}\,\mathrm{d}x+\int_{\frac{\pi}2}^{\frac{2\pi}3}\frac{\cos(x)}{1+\sin(x)}\,\mathrm{d}x$$ $$=\int_0^{\frac{\pi}2}\frac{\cos(x)}{1+\sin(x)}\,\mathrm{d}x+\int_{\frac{\pi}2}^{\frac{2\pi}3}\frac{-\sin(x-\frac{\pi}2)}{1+\cos(x-\frac{\pi}2)}\,\mathrm{d}x$$ $$=\int_0^{\frac{\pi}2}\frac{\cos(x)}{1+\sin(x)}\,\mathrm{d}x+\int_0^{\frac{\pi}6}\frac{-\sin(x)}{1+\cos(x)}\,\mathrm{d}x.$$ For the first integral, the substitution $y=\sin(x)$ is injective and results in $$\int_0^1\frac1{1+y}\,\mathrm{d}y,$$ while for the second integral, the substitution $y=\cos(x)$ is injective and results in $$\int_1^{\frac{\sqrt{3}}2}\frac1{1+y}\,\mathrm{d}y.$$ Therefore, $$\int_0^{\frac{2\pi}3}\frac{\cos(x)}{1+\sin(x)}\,\mathrm{d}x=\int_0^1\frac1{1+y}\,\mathrm{d}y+\int_1^{\frac{\sqrt{3}}2}\frac1{1+y}\,\mathrm{d}y=\int_0^{\frac{\sqrt{3}}2}\frac1{1+y}\,\mathrm{d}y=\ln\left(1+\frac{\sqrt{3}}2\right).$$ In this case, it turns out that the direct non-injective substitution gives the same result, but in general, you have to be careful.