Serving files on deployment server · Issue #5 · playframework/play-java-react-seed · GitHub
Skip to content

Serving files on deployment server #5

Open

Description

@yanlinaung30

Thanks for sharing the play & react integration source codes. I have a few problems on deployment in production mode. Could you consider how to solve the issue of my used case?

  • Back-end needs to download some images file from a server.
  • Front-end serves the files downloaded.
  • It works perfectly on development mode run by sbt run.
  • Deployment on production is done by sbt dist, unzip target/universal/xxxx.zip, cd xxx, ./bin/xxx Dplay.http.secret.key=lqkejrnjnjfajsdjfajhsdfhjasdf -Dconfig.file=/home/ubuntu/code/xxx/conf/application.conf -Dhttp.port=8080
  • Downloaded files are under xxx/public/images/
  • Front-end cannot serve the downloaded images file.
  • What I should need to change the config or controller to serve the file under xxx/public/images folder?
    Thank you.

Activity

  1. self-assigned this
    on Dec 17, 2018
  2. yohangz commented on Dec 17, 2018

    @yohangz
    Contributor

    @yanlinaung30 all the contents in public directory is directly exposed via this seed (mechanism used to server forntend source). Check the frontend asset traffic via browser dev tools network tab and use a similar kind of relative paths to access contents in public dir.

    Make sure all downloaded images are dynamically added to the public dir.

  3. yanlinaung30 commented on Dec 18, 2018

    @yanlinaung30
    Author

    @yohangz Thanks for your reply.
    public dir means Root/public or Root/xxxSNAPSHOT/public or Root/ui/public.
    I have tried all public dirs by copy & paste image files to all public folders.
    Unfortunately it does not work...

  4. yohangz commented on Dec 18, 2018

    @yohangz
    Contributor

    When you build the play project artifact all static frontend assets generated by react codebase build is copied to public directory prior to play build and bundled in jar files generated.

    Thus, if you are planing to dynamically retrieve and serve images via play framework you better keep the images in some other directory and implement a separate route to retrieve and server those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions