M
M
Mesuti2020-07-16 15:48:18
JavaScript
Mesuti, 2020-07-16 15:48:18

How to read json from gitlab repository bypassing CORS?

Hey!
The GitLab repository has a json file.
How to read it with JS bypassing CORS protection?

Tried like this, but gives CORS access error.

window.addEventListener('load', async () => {
        const url = "https://gitlab.site.ru/test/-/raw/30527fe668d5b5f5be59fa7d6b6716/data_attempts.json";
        try {
            const response = await fetch(url, {method: 'GET'});
            const json = await response.json();
            console.log(json.values);
        } catch (error) {
            console.error('Ошибка:', error);
        }
    })

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Shumov, 2020-07-16
@Mesuti

From the browser - no way. Only if you cut your server

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question