'strapi 4.0 production to aws elastic beanstalk

I’ve started seeing a strange issue recently in my deployed strapi instance.

I have it deployed on https://example.com, say. When I open my admin panel in the browser, it tries to hit http://localhost:1337/admin/project-type instead of trying to hit https://example.com/admin/project-type. This ends up with my admin panel being stuck in a “loading” state, and me getting a CORS error for trying to hit http://localhost:1337.

Strapi version: 4.1.7

buildspec.yml

version: 0.2

env:
  variables:
    NODE_ENV: "production"

phases:
  install:
    runtime-versions:
      nodejs: 14

  pre_build:
    commands:
      - echo Installing source NPM dependencies...
      - npm install

  build:
    commands:
      - echo Build started on `date`
      - echo Compiling the Node.js code
      - npm run build:prod

  post_build:
    commands:
      - echo Build completed on `date`

artifacts:
  files:
    - "**/*" 

Procfile

web: npm run start:prod



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source