Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird NetworkError with Firefox #49

Closed
Aarbel opened this issue Apr 22, 2019 · 1 comment
Closed

Weird NetworkError with Firefox #49

Aarbel opened this issue Apr 22, 2019 · 1 comment
Labels

Comments

@Aarbel
Copy link

Aarbel commented Apr 22, 2019

Hi @elbywan, thanks a lot for your work !

I face a weird error with Firefox (no errors happen in Chrome and Safari), which cause the browser to refresh.
Do you know the origin of the problem ? Format of body ?

Thanks a lot for your help !

const addAuthTokenMiddleware = next => (url, opts) => next(url, {
    ...opts,
    headers: {
        ...opts.headers,
        Authorization: `Bearer ${getToken()}`,
    },
});

const defaultWretch = wretch()
    .url('/api')
    .options({ credentials: 'include' })
    .middlewares([addAuthTokenMiddleware]);


const response = defaultWretch
    .url(url)
    .post(body)
    .json()
    .catch(error => {
        console.error('Clovis ServerApiJSON post error :', {
            error: error,
            url: url,
            body: body,
        });
    });

image

@Aarbel
Copy link
Author

Aarbel commented Apr 22, 2019

Ok i just solved the error after hours of research.

Firefox refreshes the page on default html <button> elements and consider them as "submit". That makes the wretch request fail.

Putting type="button" on the html element solved the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants