Skip to content

/upload return the url contains localhost:1337 after migrate from beta.13 to beta.17.8 #4791

@ly525

Description

@ly525

Describe the bug
when the strapi version is: 3.0.0-beta.13,
the /upload respnse is

[
    {
        "id": 1875,
        "name": "RjQkhE3OsrVv7uz.png",
        "hash": "b2c665392e044e7fb81019df4d4cd035",
        "sha256": "kfiz-6Iuc-Pcn3OCDn-Co1xCd9ieemgxSF56LYGqC5M",
        "ext": ".png",
        "mime": "image/png",
        "size": "222.58",
        "url": "/uploads/b2c665392e044e7fb81019df4d4cd035.png",
        "provider": "local",
        "provider_metadata": null,
        "created_at": "2019-12-21T14:36:17.716Z",
        "updated_at": "2019-12-21T14:36:17.716Z",
        "related": []
    }
]

but when I upgrade the strapi version to 3.0.0-beta.17.8
the /upload response is

[
    {
        "id": 1875,
        "name": "RjQkhE3OsrVv7uz.png",
        "hash": "b2c665392e044e7fb81019df4d4cd035",
        "sha256": "kfiz-6Iuc-Pcn3OCDn-Co1xCd9ieemgxSF56LYGqC5M",
        "ext": ".png",
        "mime": "image/png",
        "size": "222.58",
        "url": "http://localhost:1337/uploads/b2c665392e044e7fb81019df4d4cd035.png",
        "provider": "local",
        "provider_metadata": null,
        "created_at": "2019-12-21T14:36:17.716Z",
        "updated_at": "2019-12-21T14:36:17.716Z",
        "related": []
    }
]

Steps to reproduce the behavior

1. upload image then get http://localhost:1337/uploads/xxx.png
  1. git clone https://github.com/ly525/luban-h5
  2. cd back-end/h5-api && yarn && yarn dev
  3. visit http://localhost:1337/admin/
  4. upload image from the admin panel
  5. you will see the image url is http://localhost:1337/uploads/xxx.png
2. upload image then get /uploads/xxx.png
  1. git checkout fad25b8 # the strapi dependencies is beta.13 in this commit
  2. rm -rf node_modules && yarn && yarn dev
  3. visit http://localhost:1337/admin/
  4. upload image from the admin panel
  5. you will see the image url is http://localhost:1337/uploads/xxx.png

Expected behavior

  1. this breaks my online product and makes me confused.

  2. I do not want to config proxy in server.json and want to get {url: '/uploads/xxx.png'}, could you please do not add the host prefix url to the image url, because:

    • the host domain may change(many customers may use my product powered by strapi and they have their domain
    • we will save the image url to the database.
  3. Can strapi provide an option to keep the relative image path as before)

  4. may you please revert to {url: '/uploads/xxx.png'}? thanks a lot!

Screenshots
image

image

Code snippets
If applicable, add code samples to help explain your problem.

System

  • Node.js version: v12.13.0
  • NPM version: 6.12.0
  • Strapi version: 3.0.0-beta.17.8
  • Database: sqlite3
  • Operating system: Mac & Centos7

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions