webpack / webpack-dev-server

Serves a webpack app. Updates the browser on changes. Documentation https://webpack.js.org/configuration/dev-server/.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Axios get CORS error when I added custom headers and Authorization header also

litosh-web opened this issue · comments

Bug report

axios/axios#6190
https://stackoverflow.com/questions/77835263/axios-get-cors-error-when-i-added-custom-headers-and-authorization-header-also

Actual Behavior

I started development mode in Next.js 12. Frontend was started on localhost:3000, backend on another port and it was with a docker, nginx and php. All works well, but when I don't set headers in request. When I added custom header or Authorization header - it crashed by CORS policy.
I added all CORS policy with a signment *. I stuck with this issue already 3 days.

Expected Behavior

NO CORS policy

How Do We Reproduce?

const response = axios.get('https://api.publicapis.org/entries', {
                    headers: {
                        'X-Custom-Header': 'foobar'
                    },
                    params: data,
                }).then(res => {
                    console.log(res);
                })

Please paste the results of npx webpack-cli info here, and mention other relevant information

https://disk.yandex.ru/i/YmPDH6pEdfem6A

Axios Version
1.6.5

Adapter Version
XHR

Browser
Chrome

Browser Version
120.0.6099.224

Node.js Version
v20.5.1

OS
Windows 10

Sorry, not related to dev server. Next.js has own dev server. Feel free to feedback