Background of the issue:
I am working on a site under development and trying to resolve issues with WPML. The database is new, and nothing is in memory. I am following the documentation for different languages in catalogs, specifically for URLs like / - PL and /en/ - EN.
REST API IS ENABLED...
Symptoms:
wrong url /en/en/en/en/en/en/en/en/en.
Questions:
How can I fix the issue with the repeated '/en/' in the URL?
I checked again in much detail and discussed with the team. Apparently the problem isn't coming from WPML. Since switching to another language feature comes from WPML that's what's confusing here.
While, in fact, there's something wrong on your server side which is throwing output before any headers are sent (i.e. those PHP notices and warnings). And this is happening only when the URL is different than the default (i.e. when there's a language code in the URL like /en or /fr).
Please watch my hidden link">screen recording. And notice that it doesn't matter what is the default language, that unwanted output is thrown when switching the language. This happens in frontend and backend, even when debugging is off.
I've also created a fresh sandbox site (hidden link - one-click login), where you can try configuring WPML as you did in your site and try to reproduce the issue. This is a different environment and may help understanding the above mentioned.