Forget Korea did we?
When the Korean War started, the United States did not have diplomatic relations with the People's Republic of China. On the Security Council, China was represented by Taiwan.
At that time, communist ideology in China was very hot, and it was a matter of principle to support North Korea. Since Deng Xiaoping, China has become communist in name only.