This example uses OpenLayers v10.9.0. The latest is v.
Edit

#### COG with automatic Projection Lookup

cog 15 projection 14 proj4js 6 maptiler 26

#####

Rendering a COG over another layer in a different projection.

Example of automatically using `fromProjectionCode()` to enable a COG to be rendered over another layer in a different projection.

##### main.js

    import Map from 'ol/Map.js';
    import TileLayer from 'ol/layer/WebGLTile.js';
    import {register} from 'ol/proj/proj4.js';
    import GeoTIFF from 'ol/source/GeoTIFF.js';
    import XYZ from 'ol/source/XYZ.js';
    import proj4 from 'proj4';

    const key = 'Get your own API key at https://www.maptiler.com/cloud/';
    const attributions =
      '<a href="https://www.maptiler.com/copyright/" target="_blank">&copy; MapTiler</a> ' +
      '<a href="https://www.openstreetmap.org/copyright" target="_blank">&copy; OpenStreetMap contributors</a>';

    register(proj4);

    const cogSource = new GeoTIFF({
      sources: [
        {
          url: 'https://mikenunn.net/data/MiniScale_(std_with_grid)_R23.tif',
          nodata: 0,
        },
      ],
      loadMissingProjection: true,
    });

    cogSource.setAttributions(
      'Contains OS data © Crown Copyright and database right ' +
        new Date().getFullYear(),
    );

    const map = new Map({
      target: 'map',
      layers: [
        new TileLayer({
          source: new XYZ({
            attributions: attributions,
            url:
              'https://api.maptiler.com/maps/satellite/{z}/{x}/{y}.jpg?key=' + key,
            tileSize: 512,
            maxZoom: 20,
            crossOrigin: '',
          }),
          style: {exposure: 0.2},
        }),
        new TileLayer({
          source: cogSource,
          opacity: 0.7,
          style: {gamma: 0.7},
        }),
      ],
      view: cogSource.getView(),
    });

##### index.html

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8">
        <title>COG with automatic Projection Lookup</title>
        <link rel="stylesheet" href="node_modules/ol/ol.css">
        <style>
          .map {
            width: 100%;
            height: 400px;
          }
        </style>
      </head>
      <body>
        <div id="map" class="map"></div>

        <script type="module" src="main.js"></script>
      </body>
    </html>

##### package.json

    {
      "name": "cog-projection",
      "dependencies": {
        "ol": "10.9.0",
        "proj4": "2.20.8"
      },
      "devDependencies": {
        "vite": "^3.2.3"
      },
      "scripts": {
        "start": "vite",
        "build": "vite build"
      }
    }