French tennis star Alize Cornet took her shirt off for about three seconds in the middle of her first-round match at the US Open on Tuesday — and got penalized for it.

She scored an apology from officials, though, just hours later, after the penalty sparked an uproar on social media.

“They apologized very quickly to me,” Cornet said Wednesday. “I really appreciate it.”

Cornet, 28, was playing Sweden’s Johanna Larsson when the athletes took a mandatory 10-minute break due to the sweltering heat.

As Cornet was walking back on court, she realized her pink-striped shirt was on backward and took it off to reveal a black sports bra, before quickly putting it back on the right way.

“Usually when I put my clothes on, I put it the right way,” Cornet joked. “So my boyfriend told me, ‘Your T-shirt is reversed.’ I was like, ‘What?!’ I couldn’t play the whole third set like this.”

The 12th-year pro was slapped with a code violation by umpire Christian Rask and put her arms out in exasperation.

“Of course I was surprised . . . I didn’t expect it, and I told him it was pretty weird,” she said.

Scores of tennis pros, past and present, called out Open officials for the penalty — which stems from a Code of Conduct rule stating women must change shirts off-court.

Many pointed out that male players often take their shirts off courtside during matches and aren’t reprimanded.

The Women’s Tennis Association claimed the code violation was “not based on a WTA rule.”

In their apology, Open officials said, “We have clarified the policy to ensure this will not happen moving forward.”

Cornet lost the match to Sweden’s Johanna Larsson.