No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Api Proxy for production

    Help
    3
    6
    1210
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      geoffreylzf last edited by

      Hi all,
      According to the doc Api Proxy, this api proxy only work for development environment. But what if I need to use in production too?

      I found out on setting the production url on this doc, the problem is that all my axios instance already wrote with api word as start

      this.$axios.get('/api/something/new'),

      I wouldnt want to rewrite all the axios like

      this.$axios.get(process.env.API+'/api/something/new')

      I got search github and this forum about proxy, but almost all are refer old quasar.

      1 Reply Last reply Reply Quote 0
      • qyloxe
        qyloxe last edited by

        in production you use reverse proxy (nginx, haproxy or others) and you are set.

        G 1 Reply Last reply Reply Quote 0
        • G
          geoffreylzf @qyloxe last edited by

          @qyloxe
          Hi thx for your answer, then I would like to ask where should I define the base url in quasar app for production?

          qyloxe 1 Reply Last reply Reply Quote 0
          • qyloxe
            qyloxe @geoffreylzf last edited by

            @geoffreylzf best practice: base url === domain name.

            1 Reply Last reply Reply Quote 0
            • M
              mKomo last edited by mKomo

              If you’re going to use an external api, you can use an extension such as qenv or dotenv and set a variable such as:

              API=http://my-production-api in you dev env and API=https://my-dev-api in your prod env

              Then just set that as the base url for axios under src/boot/axios.js

              axios.defaults.baseURL = process.env.API;

              1 Reply Last reply Reply Quote 0
              • G
                geoffreylzf last edited by

                Thank you very much

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post