Giter Club home page Giter Club logo

Comments (8)

huynhttdev avatar huynhttdev commented on June 20, 2024 1

I had solution for it by update cors through API. Thanks @lafirest !

from emqx.

TrabelsiHoussem avatar TrabelsiHoussem commented on June 20, 2024 1

@huynhttdev did you find a solution for this problem ? if you find one what is it ?

from emqx.

lafirest avatar lafirest commented on June 20, 2024

@huynhttdev
You need to set the dashboard.cors to true, you can find details at here.

from emqx.

huynhttdev avatar huynhttdev commented on June 20, 2024

How can i find file config bro? @lafirest

from emqx.

windycloud avatar windycloud commented on June 20, 2024

@lafirest After set dashboard.cors is true, the error still persists because the browser makes a preflight request with the OPTIONS method, and it seems that this method is not supported.

from emqx.

id avatar id commented on June 20, 2024

@ysfscream could you assist here?

from emqx.

huynhttdev avatar huynhttdev commented on June 20, 2024

@huynhttdev did you find a solution for this problem ? if you find one what is it ?

I created nodejs demo project. In this project, I called to EMQX API without setup cors middleware. I fixed this by the following code:

const cors = require("cors");
app.use(cors());

Remember to add auth config in Axios:

const commonAxios = axios.create({
  baseURL: "",
  auth: {
    username: "",    // Can get at Emqx dashboard website
    password: "",     // Can get at Emqx dashboard website
  },
  ...
});

from emqx.

ysfscream avatar ysfscream commented on June 20, 2024

I wasn't able to replicate this issue. After obtaining the API key, I requested the remote server from my local setup, and everything worked as expected. Here is an example of my code for reference.

image

Given the uncertainties regarding the specific project environment, if you are making Axios requests to the API within a browser-based frontend project, you might need to configure a reverse proxy to circumvent the CORS issue. This approach is a standard solution, especially when frontend applications need to communicate directly with backend services. I hope this information is helpful to you.

image

from emqx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.