Hi!
Interestingly, it seems to happen with any header! For example, I get
the error if I use header X-Digitraffic-User!
I made another test. I took the JavaScript example from page
https://www.digitraffic.fi/tuki/ohjeita/ and made some minor changes -
the example seems to use a deprecated API? The code runs fine from
node.js, but not from Firefox. If I execute the HTML file in Firefox
with URL file:///home/jj/proj/tiesaa/example2.html (note the file:
protocol) I get error:
Cross-Origin Request Blocked: The Same Origin Policy disallows
reading the remote resource at
https://tie.digitraffic.fi/api/weather/v1/stations/2009. (Reason: CORS
header ‘Access-Control-Allow-Origin’ missing). Status code: 403.
I execute the Node.js version with command "node example2.js".
Both files are attached in this message. Remove the .txt suffix from both files.
I use the following versions in Fedora 38:
nodejs-18.16.0-8.fc38.x86_64
firefox-114.0.2-1.fc38.x86_64
Regards, JJ
On 6/26/23,
road.digitraffic.fi <
roaddigi...@googlegroups.com> wrote:
> Hi
>
> I tried to reproduce this with some command line magic:
>
> curl -v --http1.1 --compressed "
>
https://tie.digitraffic.fi/api/weather/v1/stations/2009" curl -v --http1.1
> --compressed -H "Digitraffic-User: digitraffic-cors-test" "
>
https://tie.digitraffic.fi/api/weather/v1/stations/2009"
>
> And I do get the CORS headers with both:
>
> < Access-Control-Allow-Origin: *
> < access-control-allow-methods: GET, POST, OPTIONS
> < access-control-allow-headers:
> DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,Digitraffic-User
> < access-control-expose-headers:
> DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,Digitraffic-User
>
> Could this be some feature of fetch? If you use any other header, do you
> then also get the CORS error?
>
>
>>
https://groups.google.com/d/msgid/roaddigitrafficfi/6f13eec9-7bbb-411f-b740-e2698e39d9c2n%40googlegroups.com
>
https://groups.google.com/d/msgid/roaddigitrafficfi/eb2ba6dc-53ec-4421-94d1-304c0dd75430n%40googlegroups.com.
>