gillchristian / tsplay.dev

TypeScript Playground Shortener
https://tsplay.dev
MIT License
67 stars 9 forks source link

Long links produce a CORS failure #63

Closed devanshj closed 4 years ago

devanshj commented 4 years ago

Afaict tsplay.dev redirects to ts-dev.now.sh but the api points to tsplay.dev/api/short hence the cors issue.

image

gillchristian commented 4 years ago

tsplay.dev does indeed redirect to tsplay-dev.now.sh, as the client and server are different applications. But CORS should be enabled.

Do you mind sharing what OS and browser was it? I was just able to create a short link from the UI (tsplay.dev/rw2Prm).

By the way, you can use the playground plugin to create short links directly there: https://www.typescriptlang.org/play?install-plugin=typescript-playground-link-shortener

Although, since it is also another domain you might also get a CORS error :thinking:

devanshj commented 4 years ago

I checked again turns out it works for mostly all links but not for this specific one. It also doesn't work with the plugin, fails with the same CORS error. First I thought maybe the custom build is the problem but it works if I just write "// test" as the content so maybe the length? idk. Still I would expect it to fail via some other error not CORS.

I'm using Chrome 85.0.4183.102 with Windows 10 OS Version 1909 (Build 18363.1016) if it helps. Also thanks for the plugin tip, I knew there's a plugin (idr where I read that) but didn't know how to install it haha.

gillchristian commented 4 years ago

First I thought maybe the custom build is the problem but it works if I just write "// test" as the content so maybe the length? idk. Still I would expect it to fail via some other error not CORS.

Looks like is the length of the link indeed but I don't know how it is related.

I started removing code and eventually managed to create it: https://tsplay.dev/pr-63-test-1

I'll look into it.

Also thanks for the plugin tip, I knew there's a plugin (idr where I read that) but didn't know how to install it haha.

That's what is there for :sweat_smile: I guess we need to add a reference to the plugin in the page.

devanshj commented 4 years ago

I'll look into it.

Thanks!

I guess we need to add a reference to the plugin in the page.

Indeed xD

gillchristian commented 4 years ago

Might not be an actual CORS issue btw, but instead just the server replaying with the wrong headers: https://stackoverflow.com/a/60537300/4530566

Which kinda makes sense, as the OPTIONS request was successful

image

image

gillchristian commented 4 years ago

Should be solved now. Here's the shortened link for your example https://tsplay.dev/lWYZ3w

devanshj commented 4 years ago

Thanks!