Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

HTML help (API request - Not plugin related)

If you have a question or need help, this is the place to be.
Post Reply
eirik226
Experienced User
Posts: 142
Joined: Wed Nov 07, 2012 5:22 pm

HTML help (API request - Not plugin related)

Post by eirik226 »

Hello again!

Explanation:

- I have a Synology NAS that runs a lot of programs, Sonarr (automatic TV-show fetch) and SabNZB (downloader).
- I have EG running on my "TV-PC" that is always on 24/7.

- SabNzb have an API that allows me to take out different stuff, like history.
- I want to display say, 3 or 5 of my latest downloaded TV shows.


I have this code:

Code: Select all

<script src="https://npmcdn.com/axios/dist/axios.min.js"></script>

Code: Select all

 <script>
                    axios.get('http://11.0.0.30:8085/sabnzbd/api=myapikey?mode=history&start=START&limit=5').then(function(response) {
                        console.log(response.data) //Write it to the page here, however you want.     
})
 </script>
The IP and port is random and API-key is removed.

When I press f12 in my browser I get this error: "No 'Access-Control-Allow-Origin' header is present on the requested resource"

and with a different code:

"No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'myip******' is therefore not allowed access. The response had HTTP status code 404. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled."

So, if I understand correctly, this is because the webpage (server) is on my home-computer and the sabnzb program is running on my NAS (With a different IP). Is that correct?

Does anyone know a way around this or could help me a bit? I'm really stuck.

Thanks in advance for any help! :)
jonib
Plugin Developer
Posts: 1328
Joined: Thu Mar 26, 2009 9:33 pm
Location: Sweden

Re: HTML help (API request - Not plugin related)

Post by jonib »

Have you configured the "List of local network ranges" in SabNZBs settings? Other than that I think you should ask in SabNZBs forum as it seems more related to SabNZB than EventGhost.

jonib
XBMC2 plugin to control XBMC. If you want to flatter me Image
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: HTML help (API request - Not plugin related)

Post by kgschlosser »

it appears as that you do not have the permissions set up properly between your "web server" and the nas. it looks as like you are trying to do a redirect to your nas instead of having your web server retrieve it and then forward the information.


eventghost does have a web server plugin that could handle everything in one package. retrieving the data from the NAS reformatting it as needed and then host a webpage for the information. this would eliminate a "layer" which would simplify the process. I am not proficient at web related connections and web hosting. but if you perhaps post a message in the Webserver plugin support thread specifically asking about how to make the connection to the SabNZBs NAS with a list of connection types the SabNZBs is able to do. someone might help you out that has experience.

That is if you would like EG to just take care of everything in one package.

here is the link to the Webserver support forum if you wanted to go that route

http://www.eventghost.org/forum/viewtop ... 1d945df6f3
If you like the work I have been doing then feel free to Image
eirik226
Experienced User
Posts: 142
Joined: Wed Nov 07, 2012 5:22 pm

Re: HTML help (API request - Not plugin related)

Post by eirik226 »

Thanks to both of you for the answer!

And yes, I am aware of the webserver plugin - that is what I am using. It's not the HTML or anything that's the problem, I am having issues with something called no coars in header, I can't recall the exact error message now. But I think i need to ask the question on the forum for sabnzb!

Thanks anyway :)
eirik226
Experienced User
Posts: 142
Joined: Wed Nov 07, 2012 5:22 pm

Re: HTML help (API request - Not plugin related)

Post by eirik226 »

kgschlosser wrote:it appears as that you do not have the permissions set up properly between your "web server" and the nas. it looks as like you are trying to do a redirect to your nas instead of having your web server retrieve it and then forward the information.
Here is the problem.

I can't get the information from the Synology NAS with the API from SabNZB to the eventghost webserver. I've read up about it, and the reason it wont work is because it's a huge security risk. I need to add something to the header of the API request to identify that I am making the request from a safe source.
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: HTML help (API request - Not plugin related)

Post by kgschlosser »

eirik226 wrote: Here is the problem.

I can't get the information from the Synology NAS with the API from SabNZB to the eventghost webserver. I've read up about it, and the reason it wont work is because it's a huge security risk. I need to add something to the header of the API request to identify that I am making the request from a safe source.

I am tellin ya ask in the webserver thread. the header can be altered easily. and if you ask Pako (one of the plugin creators) exactly what you need to add to the header. he will instruct you as to how to go about doing it. or he may alter the plugin in such a way that it can easily added without the need for altering the code. if it is something that can be easily done.

but i would ask in there with all of the information you know about as far as the API goes for the security requirements of the NAS
If you like the work I have been doing then feel free to Image
eirik226
Experienced User
Posts: 142
Joined: Wed Nov 07, 2012 5:22 pm

Re: HTML help (API request - Not plugin related)

Post by eirik226 »

kgschlosser wrote:
eirik226 wrote: Here is the problem.

I can't get the information from the Synology NAS with the API from SabNZB to the eventghost webserver. I've read up about it, and the reason it wont work is because it's a huge security risk. I need to add something to the header of the API request to identify that I am making the request from a safe source.

I am tellin ya ask in the webserver thread. the header can be altered easily. and if you ask Pako (one of the plugin creators) exactly what you need to add to the header. he will instruct you as to how to go about doing it. or he may alter the plugin in such a way that it can easily added without the need for altering the code. if it is something that can be easily done.

but i would ask in there with all of the information you know about as far as the API goes for the security requirements of the NAS
Yes, thank you! I actually got it working if I used a plugin for chrome that enabled something (can't recall what) but I disabled it due to security concerns. I'll try to set it up later sometime tho, and do it right.
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: HTML help (API request - Not plugin related)

Post by kgschlosser »

no worries boss, just trying to point ya in the right direction.

I am sure there is a way to make it work I bet you turn off some security feature in your browser to make it work. and this wouldn't be required if you handled it from inside of EG using one of the python http packages.
If you like the work I have been doing then feel free to Image
Post Reply