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

    [Solved] How can I configure rest api params (server:port) in my electron app?

    Help
    2
    3
    697
    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.
    • M
      Marco last edited by Marco

      Hello guys,

      I’m struggling with my first electron app.

      A button triggers a rest api call:

      this.$axios.post(’/api/v1’, …

      It fails (Network Error) …

      Where do I configure my app to use the real url?:
      http://<server>:<port>/api/v1

      I have had no problems with the spa version.

      Thanks

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

        Check out the quasar extension dotenv (or the newly released qenv - but I may be mistaken). The way I have this set up is with a dev env and a production env which allows you to use your respective dev or production api.

        You can then reference and set your base url in the boot axios file located at src/boot/axios.js via:

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

        In my case process.env.API = "http://localhost:8000/api"

        If you’re just looking to set the api url just set axios.defaults.baseURL directly

        1 Reply Last reply Reply Quote 1
        • M
          Marco last edited by

          Thank you mKomo, it works!
          I’m just a newbie.

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