mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-01-23 14:48:13 -05:00
✨ Feature: add server response headers for CORS (#939)
Co-authored-by: long <iamlongalong@gmail.com>
This commit is contained in:
parent
0a9e1692ee
commit
fb69bad2cf
@ -39,13 +39,19 @@ class Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private handleRequest = (request: http.IncomingMessage, response: http.ServerResponse) => {
|
private handleRequest = (request: http.IncomingMessage, response: http.ServerResponse) => {
|
||||||
|
if (request.method === 'OPTIONS') {
|
||||||
|
handleResponse({
|
||||||
|
response
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (request.method === 'POST') {
|
if (request.method === 'POST') {
|
||||||
if (!routers.getHandler(request.url!)) {
|
if (!routers.getHandler(request.url!)) {
|
||||||
logger.warn(`[PicGo Server] don't support [${request.url}] url`)
|
logger.warn(`[PicGo Server] don't support [${request.url}] url`)
|
||||||
handleResponse({
|
handleResponse({
|
||||||
response,
|
response,
|
||||||
statusCode: 404,
|
statusCode: 404,
|
||||||
header: {},
|
|
||||||
body: {
|
body: {
|
||||||
success: false
|
success: false
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,10 @@ export const handleResponse = ({
|
|||||||
response,
|
response,
|
||||||
statusCode = 200,
|
statusCode = 200,
|
||||||
header = {
|
header = {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json',
|
||||||
|
'access-control-allow-headers': '*',
|
||||||
|
'access-control-allow-methods': 'POST, GET, OPTIONS',
|
||||||
|
'access-control-allow-origin': '*'
|
||||||
},
|
},
|
||||||
body = {
|
body = {
|
||||||
success: false
|
success: false
|
||||||
|
@ -140,7 +140,8 @@ export default class extends Vue {
|
|||||||
pluginNameList: string[] = []
|
pluginNameList: string[] = []
|
||||||
loading = true
|
loading = true
|
||||||
needReload = false
|
needReload = false
|
||||||
pluginListToolTip = this.$T('PLUGIN_LIST')importLocalPluginToolTip = this.$T('PLUGIN_IMPORT_LOCAL')
|
pluginListToolTip = this.$T('PLUGIN_LIST')
|
||||||
|
importLocalPluginToolTip = this.$T('PLUGIN_IMPORT_LOCAL')
|
||||||
id = ''
|
id = ''
|
||||||
os = ''
|
os = ''
|
||||||
defaultLogo: string = 'this.src="https://cdn.jsdelivr.net/gh/Molunerfinn/PicGo@dev/public/roundLogo.png"'
|
defaultLogo: string = 'this.src="https://cdn.jsdelivr.net/gh/Molunerfinn/PicGo@dev/public/roundLogo.png"'
|
||||||
|
Loading…
Reference in New Issue
Block a user