I am encountering issues with Axios when bundled with electron - what steps can I take to troubleshoot a compiled exe with electron?

I recently developed a VUE JS application that consumes data from a News API endpoint. To achieve this, I utilized Axios for fetching the data as shown below:

import axios from "axios";
let baseURL = `https://newsapi.org/v2`;
let apiKey = process.env.VUE_APP_APIKEY;
const instance = axios.create({
    baseURL: baseURL,
    timeout: 30000,
    headers: {
        "X-Api-Key": apiKey,
    },
});
export default instance;

Upon running npm run electron:serve, the application successfully retrieves data from the API.

https://i.stack.imgur.com/wygv3.png

However, when I compile the application using npm run electron:build, the Axios call seems to stop working. I even attempted removing the environment variable and directly entering the API key for testing purposes, but it still doesn't function properly after compilation. How can I effectively troubleshoot an Electron-built executable?

https://i.stack.imgur.com/WQLPS.png

The relevant sections in my package.json are outlined below:

 
  // Package.json scripts and dependencies listed here

Answer №1

If you're curious about troubleshooting, I utilized a handy app named HTTP Toolkit. This app has the capability to connect with the electron app and provides visibility into the http(s) requests being transmitted.

Interestingly, in this scenario, the API requests are originating from app:// which causes a CORS issue, hence why it ceased functioning properly. It worked fine on localhost during serving, demonstrating that the problem arose specifically when building the application.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a Vue component using v-for and a factory function allows for dynamic

I am currently developing a Table component using factory functions for all logic implementation. Within a v-for loop, I generate a cell for each item in every row. The factory Below are the actual factories that I import into the respective vue page whe ...

Exploring the intersection of Nuxt and TypeScript with the powerful `defineProps`

I am currently utilizing the Nuxt 3 / Vue 3 defineProps in conjunction with TypeScript and I am looking to automatically deduce prop types from TypeScript types. import { User } from '~/types/types' const props = defineProps({ users: { typ ...

Markdown in Vue.js filters

I found a helpful example by Evan You on how to convert HTML to markdown - check it out here. However, when trying to install the marked package via npm and implementing it, I encountered an error stating that 'marked' is not defined. After inc ...

Ensuring that at least one checkbox is selected with the help of vuejs

Ensuring that at least one checkbox is checked and the correct price is calculated is my priority. https://jsfiddle.net/snoke/1xrzy57u/1/ methods: { calc: function (item) { item.isChecked = !item.isChecked this.total = 0; for ...

Prevent the click event from passing down to the child component in Vue 2

After including the following HTML structure: <div @click='handleClickOnDiv'> {{ message }} <i class='fa fa-plus' @click.stop='handleClickOnI'></i> </div> When clicking on the div, it triggers ...

Navigating with Vue Router in a Nuxt JS vuex Store

In my app, I'm currently developing a login/register system using Firebase and Vuex for authentication and database management. Within Nuxt JS, I have implemented actions to create a user, log them in, and sign them out. After a successful registrati ...

Electron Searching for Files in Main Directory

We have developed a web application using Angular 2, but we are facing an issue when trying to run it as an Electron application. After branching out the solution and making changes to package.json to launch Electron on start, we encountered an unexpected ...

Tips for designing a multi-level dropdown navbar

I am currently facing an issue with designing a navbar. I am aiming for Multi-Level Dropdowns, but whenever I click on More Services, it automatically closes the main dropdown menu. I have experimented with various approaches, but none of them seem to be ...

The functionality of updating the logo in the browser tabs is not functioning as expected in Vue.js 3

This is the code from my index.html: <!DOCTYPE html> <html lang=""> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE ...

Manipulating arrays and troubleshooting Typescript errors in Vue JS

I am attempting to compare the elements in one list (list A) with another list (list B), and if there is a match, I want to change a property/field of the corresponding items in list B to a boolean value. Below is the code snippet: export default defineCo ...

The dilemma between installing Electron or installing Electron-Builder: which one

When it comes to installing Electron for an Electron app with React, the method can vary depending on the tutorial. Some tutorials use electron-builder while others do not, but there is little explanation as to why. First: npx create-react-app app cd app ...

What is the best way to responsively center an after pseudo-element above its parent?

Looking to create a dynamic tooltip without any fixed widths or constraints on the parent element. The process seems simple enough, but I'm facing an issue with centering the after element due to an existing transform attribute of transform: translat ...

Sorting in Vuejs fails to function properly when a filter is applied

Having recently delved into Laravel and Vue, I am eager to develop a site for our Intranet. Pulling data from the Laravel database has been successful, displaying the data works well, and the search functionality is also up and running smoothly. However, I ...

Retrieve the index of a v-for loop and then send it as a parameter to a specific function

When working with a select element generated by a v-for loop in Vue, it is important to be able to retrieve the index of the selected option. This way, you can use that index in a function for further processing. However, I have been struggling to achieve ...

Positioning Input and Dropdown Elements within a Data Table Using CSS

I am currently working on setting up a data table for an application using Vue.js, and I am facing a challenge in relation to the arrangement of input elements. The specific requirement is that certain columns within the table should contain values that ar ...

Is it possible to dispatch actions from getters in Vuex?

Fiddle : here Currently, I am in the process of developing a web application using Vue 2 with Vuex. Within my store, I aim to retrieve state data from a getter. My intention is for the getter to trigger a dispatch and fetch the data if it discovers that t ...

Press the button within the nested component to send information to the parent component through another intermediate child component

Can data be passed by clicking on a button in a nested child component, then passed to another child component one level above, and finally to the parent component? This is how my components are nested: Parent ----Child ---------Child 2 (with a button th ...

Having problems with installing npm packages via vue-cli?

Encountering an issue with npm while trying to install @vue/cli: Received a warning about skipping optional dependency [email protected] due to unsupported platform for fsevents. Error message also includes file path and code syntax issues. Error log is ...

SMTPConnection._formatError experienced a connection timeout in Nodemailer

Our email server configuration using Nodemailer SMTP settings looked like this: host: example.host port: 25 pool: true maxConnections: 2 authMethod: 'PLAIN' auth: user: 'username' pass: 'pass' We encou ...

Tips for integrating html2canvas with Vue JS?

One hurdle I encountered was the absence of a shorthand for document.getElementById in Vue. To address this, I created a custom function similar to this one. Another challenge I am currently grappling with is the perceived limitations of the html2canvas do ...