Cheesegeezer 3089 Posted April 22, 2022 Share Posted April 22, 2022 What am i doing wrong? Please can someone help me. I'm going crazy.... Using VSCode and it keeps putting the file location in with the URL request, i've tried just launching the page direct. When i remove the file location from the request manually, i can see the json info in the webpage. it's just that the requests are always prepending this info. I'm not worried about the CORS policy as that will be fine once the dang file location is removed. Quote Access to fetch at 'file:///C:/Users/davey/Documents/GitHub/Iridium.Emby/Connecting/ServerSelect/192.168.0.117:8096/emby/System/Info/Public' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, edge, https, chrome-untrusted. this is the code to connect var appStorage = '../embyAPI/appstorage-cache.js'; var apiClient, url, port; var appName = "Iridium"; var appVersion = "1.0.0.0"; var deviceName = navigator.userAgent; var deviceId = "IridiumApp"; var discoverContainer = document.querySelector('.serverdiscovery'); var loginContainer = document.querySelector('.login'); var userNameInput = document.querySelector('#username') var passwordInput = document.querySelector('#password') document.querySelector('.connectButton').addEventListener('click', (e) => { e.preventDefault(); var urlInput = document.querySelector('#discoverUrl'); var portInput = document.querySelector('#discoverPort'); url = urlInput.value; port = portInput.value; apiClient = new ApiClient(appStorage, wol, url + ":" + port, appName, appVersion, deviceName, deviceId); apiClient.getPublicSystemInfo().then(function(systemInfo) { Headers are correct I think in the request: accept: application/json Referer User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 Edg/100.0.1185.44 X-Emby-Authorization: MediaBrowser Client="Iridium", Device="Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F100.0.4896.127%20Safari%2F537.36%20Edg%2F100.0.1185.44", DeviceId="IridiumApp", Version="1.0.0.0" Help me obi-wan... you're my only hope!! thanks Link to comment Share on other sites More sharing options...
Cheesegeezer 3089 Posted April 22, 2022 Author Share Posted April 22, 2022 maybe it is sending it correctly ApiClient serverAddress: 192.168.0.117:8096 apiclient.js:634 ApiClient appName: Iridium apiclient.js:635 ApiClient appVersion: 1.0.0.0 apiclient.js:636 ApiClient deviceName: Edge apiclient.js:637 ApiClient deviceId: IridiumApp apiclient.js:805 apiclient.fetchWithFailover 192.168.0.117:8096/emby/System/Info/Public apiclient.js:76 apiclient.js:836 Request failed to 192.168.0.117:8096/emby/System/Info/Public TypeError: Failed to fetch apiclient.js:841 Attempting reconnection apiclient.js:167 tryReconnect: apiclient.js:196 error in tryReconnectInternal: apiclient.js:167 tryReconnect: apiclient.js:196 error in tryReconnectInternal: apiclient.js:167 tryReconnect: apiclient.js:196 Link to comment Share on other sites More sharing options...
Luke 37178 Posted April 22, 2022 Share Posted April 22, 2022 Are you trying to do this from the file system? You should instead spin up an http server pointing to the directory of your source files, and then do your debugging with that. If you install nodejs and http-server, it's as easy as: http-server -p 8088 -c -1 Using the file protocol you'll run into browser security restrictions so I wouldn't do that. Link to comment Share on other sites More sharing options...
Cheesegeezer 3089 Posted April 22, 2022 Author Share Posted April 22, 2022 26 minutes ago, Luke said: Are you trying to do this from the file system? You should instead spin up an http server pointing to the directory of your source files, and then do your debugging with that. If you install nodejs and http-server, it's as easy as: http-server -p 8088 -c -1 Using the file protocol you'll run into browser security restrictions so I wouldn't do that. Thanks luke, nope I’m actually just launching either from the folder (opening direct html) or thru live server extension in vsCode. i was creating the pages for Iridium and they are all fine accessing the server api(however just using fetch(url) at the minute), but when trying to use the Emby.ApiClient for js and this is where it’s falling down. ive got nodesjs installed, just trying to keep it clean with pure JS at the minute, then i will convert to nodeJS Link to comment Share on other sites More sharing options...
roaku 797 Posted April 22, 2022 Share Posted April 22, 2022 4 hours ago, Cheesegeezer said: What am i doing wrong? Please can someone help me. I'm going crazy.... Using VSCode and it keeps putting the file location in with the URL request, i've tried just launching the page direct. When i remove the file location from the request manually, i can see the json info in the webpage. it's just that the requests are always prepending this info. I'm not worried about the CORS policy as that will be fine once the dang file location is removed. this is the code to connect var appStorage = '../embyAPI/appstorage-cache.js'; var apiClient, url, port; var appName = "Iridium"; var appVersion = "1.0.0.0"; var deviceName = navigator.userAgent; var deviceId = "IridiumApp"; var discoverContainer = document.querySelector('.serverdiscovery'); var loginContainer = document.querySelector('.login'); var userNameInput = document.querySelector('#username') var passwordInput = document.querySelector('#password') document.querySelector('.connectButton').addEventListener('click', (e) => { e.preventDefault(); var urlInput = document.querySelector('#discoverUrl'); var portInput = document.querySelector('#discoverPort'); url = urlInput.value; port = portInput.value; apiClient = new ApiClient(appStorage, wol, url + ":" + port, appName, appVersion, deviceName, deviceId); apiClient.getPublicSystemInfo().then(function(systemInfo) { Headers are correct I think in the request: accept: application/json Referer User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 Edg/100.0.1185.44 X-Emby-Authorization: MediaBrowser Client="Iridium", Device="Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F100.0.4896.127%20Safari%2F537.36%20Edg%2F100.0.1185.44", DeviceId="IridiumApp", Version="1.0.0.0" Help me obi-wan... you're my only hope!! thanks Just a wild guess here, but do you need to prepend 'http/s' to your url before passing it to the ApiClient as a constructor parameter? 1 Link to comment Share on other sites More sharing options...
Cheesegeezer 3089 Posted April 22, 2022 Author Share Posted April 22, 2022 11 minutes ago, roaku said: Just a wild guess here, but do you need to prepend 'http/s' to your url before passing it to the ApiClient as a constructor parameter? I’m use the official emby.ApiClient and you have to pass these args to the constructor. I will certainly give it a shotty tho. That might be it you know thinking about it. thanks fella Link to comment Share on other sites More sharing options...
Cheesegeezer 3089 Posted April 23, 2022 Author Share Posted April 23, 2022 22 hours ago, roaku said: Just a wild guess here, but do you need to prepend 'http/s' to your url before passing it to the ApiClient as a constructor parameter? You were exactly correct on the http missing. I foolishly assumed that the api client would add this to the calls. Doh!! thanks again chief, such a simple think to overlook!! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now